New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

feproxy

Package Overview
Dependencies
Maintainers
2
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

feproxy - npm Package Compare versions

Comparing version 3.0.3 to 3.0.4

lib/inspector/Client.js

6

bin/feproxy.js
#! /usr/bin/env node
const argv = require('yargs')
.alias('p', 'port')
.describe('port', 'Service port')
.describe('https', 'Capture and modify https request')
.describe('config', 'Directory fo config files')
.alias('v', 'version')
.describe('version', 'output the version number')
.describe('version', 'Output the version number')
.help('help')

@@ -7,0 +11,0 @@ .argv;

@@ -0,1 +1,22 @@

## [3.0.4](https://github.com/feix760/feproxy/compare/v3.0.3...v3.0.4) (2019-07-17)
### Bug Fixes
* alivesocket id fix ([ae2fdea](https://github.com/feix760/feproxy/commit/ae2fdea))
* app stop error fix ([dd1906f](https://github.com/feix760/feproxy/commit/dd1906f))
* block request url match fix ([412019f](https://github.com/feix760/feproxy/commit/412019f))
* decode content bugfix ([7e5f56e](https://github.com/feix760/feproxy/commit/7e5f56e))
* stop fix ([9bf0726](https://github.com/feix760/feproxy/commit/9bf0726))
### Features
* devtool setBlockedURLs ([de69f59](https://github.com/feix760/feproxy/commit/de69f59))
* reject handshake to no route ws ([9ac0ca8](https://github.com/feix760/feproxy/commit/9ac0ca8))
* support conent-encoding br ([c106980](https://github.com/feix760/feproxy/commit/c106980))
* Support Network.replayXHR ([61f3eb3](https://github.com/feix760/feproxy/commit/61f3eb3))
## [3.0.3](https://github.com/feix760/feproxy/compare/v3.0.2...v3.0.3) (2019-07-04)

@@ -2,0 +23,0 @@

34

lib/App.js

@@ -7,2 +7,4 @@ const path = require('path');

const WebSocketServer = require('./server/WebSocketServer');
const ProxyServer = require('./server/ProxyServer');
const Inspector = require('./inspector/Inspector');
const Config = require('./util/Config');

@@ -13,4 +15,2 @@

app.ws = new WebSocketServer(app);
app.config = new Config({

@@ -23,4 +23,6 @@ ...require('./config.default'),

app.inspect = require('./inspect')(app);
app.ws = new WebSocketServer(app);
app.inspector = new Inspector(app);
app.proxyPlugins = require('./proxyPlugins')(app);

@@ -37,19 +39,17 @@

const server = require('./server/server')(app);
const server = new ProxyServer(app);
app.start = () => new Promise(resolve => {
server.listen(app.config.port, () => {
console.log(chalk.green(`\n👉 Proxy server http://${ip.address()}:${app.config.port}`));
console.log(chalk.green(`🚀 Inspect page http://${ip.address()}:${app.config.port}/admin.html`));
resolve();
});
});
app.start = async () => {
await server.listen(app.config.port);
app.stop = () => new Promise(resolve => {
server.close(() => {
console.log(chalk.gray('👂 Stopped'));
resolve();
});
});
console.log(chalk.green(`\n👉 Proxy server http://${ip.address()}:${app.config.port}`));
console.log(chalk.green(`🚀 Inspect page http://${ip.address()}:${app.config.port}/admin.html`));
};
app.stop = async () => {
await server.close();
console.log(chalk.gray('👂 Stopped'));
};
app.on('error', (err, ctx) => {

@@ -56,0 +56,0 @@ console.error(ctx.url, err);

@@ -19,3 +19,3 @@

module.exports = async ctx => {
exports.static = async ctx => {
const filename = ctx.params[0];

@@ -28,1 +28,19 @@ const filepath = path.join(localFiles.includes(filename) ? localDevTools : chromeDevTools, filename);

};
function extendWebsocket(ws) {
const originSend = ws.send;
ws.send = obj => {
if (typeof obj === 'object') {
obj = JSON.stringify(obj);
}
originSend.call(ws, obj);
};
}
exports.ws = async ctx => {
const ws = await ctx.accept();
extendWebsocket(ws);
ctx.app.inspector.addClient(ws);
};
module.exports = async (ctx, next) => {
ctx.app.inspect.emit('requestWillBeSent', ctx);
ctx.app.inspector.emit('requestWillBeSent', ctx);
await next();
ctx.app.inspect.emit('responseReceived', ctx);
ctx.app.inspector.emit('responseReceived', ctx);
};

@@ -17,3 +17,5 @@

ctx.app.config.getRules().forEach(rule => {
const rules = ctx.app.config.getRules(ctx.app.inspector.getBlockedURLs());
rules.forEach(rule => {
if (proxyPlugins[rule.type]) {

@@ -20,0 +22,0 @@ matchPlugin(rule.type, rule.match, rule.param);

@@ -52,3 +52,3 @@

res.on('error', err => {
console.error('res error', err.code || '');
console.error('Response error', urlInfo.href, err.code || '');
});

@@ -58,3 +58,3 @@ resolve({ req, res });

req.on('error', err => {
console.error('req error', urlInfo.href, err.code || '');
console.error('Request error', urlInfo.href, err.code || '');
reject(err);

@@ -61,0 +61,0 @@ });

@@ -23,4 +23,4 @@

let hangList = [];
res.on('close', onclose)
.on('error', onclose)
res.once('close', onclose)
.once('error', onclose)
.on('message', msg => {

@@ -36,6 +36,6 @@ try {

let headers;
res.on('upgrade', response => {
res.once('upgrade', response => {
headers = response.headers;
})
.on('open', () => resolve(headers))
.once('open', () => resolve(headers))
.once('error', reject);

@@ -54,4 +54,4 @@ });

ws.on('close', onclose)
.on('error', onclose)
ws.once('close', onclose)
.once('error', onclose)
.on('message', msg => {

@@ -58,0 +58,0 @@ try {

@@ -5,3 +5,2 @@

const controller = {
devtoolsWS: require('./controller/devtoolsWS'),
site: require('./controller/site'),

@@ -12,3 +11,3 @@ devtools: require('./controller/devtools'),

inspect: require('./middleware/inspect'),
inspectWebsocket: require('./middleware/inspectWebsocket'),
wsInspect: require('./middleware/wsInspect'),
proxy: require('./middleware/proxy'),

@@ -32,3 +31,3 @@ };

const wsURL = /^wss?:\/\/.*/i;
router.all(wsURL, middleware.inspectWebsocket);
router.all(wsURL, middleware.wsInspect);
router.all(wsURL, middleware.proxy);

@@ -44,5 +43,5 @@

// chrome inspect websocket
router.get('/ws', controller.devtoolsWS);
// devtools
router.get(/\/devtools\/(.+)/, controller.devtools);
router.get('/ws', controller.devtools.ws);
// devtools static files
router.get(/\/devtools\/(.+)/, controller.devtools.static);

@@ -49,0 +48,0 @@ // use routes to app

const compose = require('koa-compose');
const co = require('co');
const ws = require('ws');

@@ -55,9 +54,10 @@

verifyClient(info, cb) {
async verifyClient(info, cb) {
const { req } = info;
const ctx = this.createContext(req);
let hasAccept = false;
// args same as verifyClient's cb args
// ref: https://github.com/websockets/ws/blob/master/doc/ws.md#new-websocketserveroptions-callback
ctx.accept = (result = true, ...args) => {
ctx.accept = () => {};
hasAccept = true;
const promise = new Promise(resolve => {

@@ -76,7 +76,13 @@ if (result) {

};
const fn = co.wrap(compose(this.middleware));
fn(ctx).catch(err => {
ctx.accept(false, 500); // server error
let hasError = false;
try {
await compose(this.middleware)(ctx);
} catch (err) {
hasError = true;
console.error(err);
});
}
if (!hasAccept) {
ctx.accept(false, hasError ? 500 : 404);
}
}

@@ -83,0 +89,0 @@

@@ -5,3 +5,5 @@

const ip = require('ip');
const escapeStringRegexp = require('escape-string-regexp');
const RULES = Symbol('RULES');
const BLOCKED_URLS_CACHE = Symbol('BLOCKED_URLS_CACHE');

@@ -80,4 +82,23 @@ class Config {

getRules() {
return this[RULES];
getRules(blockedURLs) {
const key = blockedURLs.join(',');
let cache = this[BLOCKED_URLS_CACHE];
if (!cache || cache.key !== key) {
const rules = blockedURLs.map(url => {
return {
type: 'status',
match: new RegExp(`${escapeStringRegexp(url).replace(/\\\*/g, '.*')}`),
param: {
status: 404,
},
};
});
this[BLOCKED_URLS_CACHE] = cache = {
key,
rules,
};
}
return [ ...cache.rules, ...this[RULES] ];
}

@@ -84,0 +105,0 @@ }

{
"name": "feproxy",
"version": "3.0.3",
"version": "3.0.4",
"description": "An node proxy server for web development",

@@ -20,6 +20,7 @@ "scripts": {

"dependencies": {
"brotli": "^1.3.2",
"chalk": "^2.3.2",
"chrome-devtools-frontend": "1.0.661035",
"co": "^4.6.0",
"cross-env": "^5.2.0",
"escape-string-regexp": "^2.0.0",
"fs-extra": "^5.0.0",

@@ -70,2 +71,3 @@ "get-port": "^5.0.0",

"jest": "^24.8.0",
"jsdom": "^15.1.1",
"mini-css-extract-plugin": "^0.7.0",

@@ -127,2 +129,9 @@ "node-sass": "^4.9.4",

],
"coverageReporters": [
"json",
"lcov",
"text",
"clover",
"text-summary"
],
"coverageThreshold": {

@@ -136,5 +145,6 @@ "global": {

},
"testRegex": "test/.*\\.test\\.[jt]s$"
"testRegex": "test/.*\\.test\\.[jt]s$",
"testEnvironment": "node"
},
"license": "MIT"
}

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc