Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const net = require('net');
const edgeconfig = require('microgateway-config');
const gateway = require('microgateway-core');
const reloadCluster = require('./reload-cluster');
const JsonSocket = require('../../third_party/json-socket/json-socket');
const configLocations = require('../../config/locations');
const isWin = /^win/.test(process.platform);
const ipcPath = configLocations.getIPCFilePath();
const pidPath = configLocations.getPIDFilePath();
const defaultPollInterval = 600;
const uuid = require('uuid/v1');
const debug = require('debug')('microgateway');
const jsdiff = require('diff');
const _ = require('lodash');
//const os = require('os');
const writeConsoleLog = require('microgateway-core').Logging.writeConsoleLog;
edgeconfig.setConsoleLogger(writeConsoleLog);
const Gateway = function() {};
const CONSOLE_LOG_TAG_COMP = 'microgateway gateway';
module.exports = function() {
return new Gateway();
};
// initializeMicroGatewayLogging
// All logging is initialized here.
// For logging to happend xalling initializeMicroGatewayLogging is required at some point early on in
// the flow of configuration
function initializeMicroGatewayLogging(config,options) {
// gateway from require
'use strict'
var cluster = require('cluster');
var EventEmitter = require('events').EventEmitter;
var cpuCount = require('os').cpus().length;
const cache = require('microgateway-plugins').memored;
const writeConsoleLog = require('microgateway-core').Logging.writeConsoleLog;
const CONSOLE_LOG_TAG_COMP = 'microgateway reload cluster';
const specialLists = require('./util/item-managers')
const PURGE_INTERVAL = 60000;
//
const DEFAULT_PROCESS_CHECK_INTERVAL = 10000
const RAPID_REPLAY_INTERVAL_STOPPED_PROCESSES = 50
const CALLBACK_TIMEOUT = 5000
const MAX_CONNECT_FAIL_TIME = 200
const WORKER_CHECKSTATUS_INTERVAL = 100
const WORKER_FORCEKILL_TIMEOUT = 1000 * 180 // 3 minutes
//
var RLC = null; // an instance if needed
var gExitCounter = null;
'use strict'
const gateway = require('./gateway');
const assert = require('assert');
const os = require('os');
const url = require('url');
//const path = require('path');
//const _ = require('lodash');
//const cluster = require('cluster')
const writeConsoleLog = require('microgateway-core').Logging.writeConsoleLog;
/**
* new agent
*/
const Agent = function () {
};
const CONSOLE_LOG_TAG_COMP = 'microgateway server';
module.exports = function () {
return new Agent();
};
// use to close down the current agent connections
Agent.prototype.close = function close(cb) {
if (this.gatewayServer) {
this.gatewayServer.stop();
'use strict'
const fs = require('fs')
const path = require('path');
const configLocations = require('../../config/locations');
const writeConsoleLog = require('microgateway-core').Logging.writeConsoleLog;
const CONSOLE_LOG_TAG_COMP = 'microgateway init';
module.exports = function init(opts, cb) {
if(typeof opts === 'function') {
cb = opts;
}
const setupConfigPath = (srcFile, destFile, destFileDir, cb) => {
if(fs.existsSync(destFile)) {
fs.unlinkSync(destFile);
}
fs.mkdir(destFileDir, () => {
copyFile(srcFile, destFile, (err) => {
'use strict';
const edgeconfig = require('microgateway-config')
//const prompt = require('cli-prompt');
//const path = require('path');
//const apigeetool = require('apigeetool');
//const _ = require('lodash');
const async = require('async')
const util = require('util')
const fs = require('fs')
const assert = require('assert');
const writeConsoleLog = require('microgateway-core').Logging.writeConsoleLog;
edgeconfig.setConsoleLogger(writeConsoleLog);
const configLocations = require('../../config/locations');
const BUFFERSIZE = 10000;
const BATCHSIZE = 500;
const FLUSHINTERVAL = 5000;
var defaultConfig ;
const CONSOLE_LOG_TAG_COMP = 'microgateway configure';
var certLib = require('./cert-lib')
var cert;
var deployAuthLib = require('./deploy-auth')
var deployAuth;
var authUri, managementUri, keySecretMessage, targetFile;
'use strict';
var forever = require('forever-monitor');
const writeConsoleLog = require('microgateway-core').Logging.writeConsoleLog;
const CONSOLE_LOG_TAG_COMP = 'microgateway forever';
try {
var foreverOptions = require('./forever.json');
} catch (err) {
writeConsoleLog('error',{component: CONSOLE_LOG_TAG_COMP},err);
writeConsoleLog('log',{component: CONSOLE_LOG_TAG_COMP},"using default forever options");
var foreverOptions = { max: 3, silent: false, killTree: true, minUptime: 2000 };
}
var child = new (forever.Monitor)('./app.js', foreverOptions);
child.start();
'use strict';
const commander = require('commander');
const token = require('./lib/token')();
const writeConsoleLog = require('microgateway-core').Logging.writeConsoleLog;
const CONSOLE_LOG_TAG_COMP = 'microgateway cmd token';
const setup = function setup() {
commander
.command('decode')
.option('-f, --file ', 'file containing jwt')
.description('decode a token without verifying it')
.action((options)=>{
options.error = optionError(options);
if (!options.file) {return options.error( 'file is required' );}
token.decodeToken(options)
});
commander
"use strict";
//const util = require("util");
//const debug = require("debug")("jwkrotatekey");
//const request = require("request");
var deployAuthLib = require('./deploy-auth');
var deployAuth;
const path = require('path');
const writeConsoleLog = require('microgateway-core').Logging.writeConsoleLog;
const CONSOLE_LOG_TAG_COMP = 'microgateway upgrade edgeauth';
const UpgradeAuth = function() {
}
module.exports = function() {
return new UpgradeAuth();
}
UpgradeAuth.prototype.upgradeauth = function upgradeauth(options /*, cb */) {
const opts = {
org: options.org,
env: options.env,
username: options.username,
'use strict';
const cert = require('./cert-lib')
const edgeconfig = require('microgateway-config');
const util = require('util');
const configLocations = require('../../config/locations');
const assert = require('assert')
//const prompt = require('cli-prompt');
//const path = require('path');
//const apigeetool = require('apigeetool');
//const _ = require('lodash');
//const async = require('async');
const writeConsoleLog = require('microgateway-core').Logging.writeConsoleLog;
edgeconfig.setConsoleLogger(writeConsoleLog);
const CONSOLE_LOG_TAG_COMP = 'microgateway cert';
const Cert = function() {
};
module.exports = function() {
return new Cert();
};
Cert.prototype.installCert = function(options, cb) {
if ( !options.username && !options.token ) {
return options.error('username is required');
}
if ( !options.org ) {
'use strict';
var request = require('request');
var url = require('url');
var fs = require('fs');
var run = require('./cli/lib/gateway')();
var portastic = require('portastic');
const os = require('os');
const writeConsoleLog = require('microgateway-core').Logging.writeConsoleLog;
const options = {};
const CONSOLE_LOG_TAG_COMP = 'microgateway app';
options.env = process.env.EDGEMICRO_ENV;
options.key = process.env.EDGEMICRO_KEY;
options.secret = process.env.EDGEMICRO_SECRET;
options.org = process.env.EDGEMICRO_ORG;
options.configDir = process.env.EDGEMICRO_CONFIG_DIR || os.homedir()+"/.edgemicro";
options.configUrl = process.env.EDGEMICRO_CONFIG_URL;
options.processes = process.env.EDGEMICRO_PROCESSES || os.cpus().length;
options.pluginDir = process.env.EDGEMICRO_PLUGIN_DIR;
options.apiProxyName = process.env.EDGEMICRO_API_PROXYNAME;
options.revision = process.env.EDGEMICRO_API_REVISION;
options.basepath = process.env.EDGEMICRO_API_BASEPATH;
options.target = process.env.EDGEMICRO_API_TARGET;