Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@glimpse/glimpse-server

Package Overview
Dependencies
Maintainers
6
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@glimpse/glimpse-server - npm Package Compare versions

Comparing version 0.20.8 to 0.20.9

release/definitions/src/glimpse.d.ts

11

package.json
{
"name": "@glimpse/glimpse-server",
"version": "0.20.8",
"client": "v0.20.8",
"hud": "v0.20.8",
"browserAgent": "v0.20.8",
"version": "0.20.9",
"client": "v0.20.9",
"hud": "v0.20.9",
"browserAgent": "v0.20.9",
"license": "See license in license.md",

@@ -35,3 +35,3 @@ "main": "./release/src/glimpse.js",

"dependencies": {
"@glimpse/glimpse-common": "0.20.8",
"@glimpse/glimpse-common": "0.20.9",
"body-parser": "^1.14.2",

@@ -70,2 +70,3 @@ "cors": "^2.7.1",

"gulp-util": "^3.0.7",
"merge2": "^1.0.3",
"remap-istanbul": "^0.6.3",

@@ -72,0 +73,0 @@ "request": "^2.74.0",

@@ -7,3 +7,3 @@ 'use strict';

function setupProxy() {
// Note: http.createServer and https.createServer have differnt signatures,
// Note: http.createServer and https.createServer have different signatures,
// so we do each one separately here to keep things simple, even if there is

@@ -13,12 +13,15 @@ // some duplicated code

// tslint:disable-next-line:no-any
http.createServer = function createServer(callback) {
http.createServer = function createServer() {
var args = [];
for (var _i = 1; _i < arguments.length; _i++) {
args[_i - 1] = arguments[_i];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
var app = buildApp(callback);
var server = oldHttpCreateServer.call.apply(oldHttpCreateServer, [this, app].concat(args));
server.on('listening', function () {
glimpse_common_1.printBannerGreeting("http://localhost:" + server.address().port + "/glimpse/client");
});
var callback;
if (args.length && typeof args[0] === 'function') {
callback = args[0];
args.splice(0, 1);
}
// NOTE: The callback is not passed through to the old createServer() (as it's added later).
var server = oldHttpCreateServer.apply(this, args);
patchServer(server, callback, 'http');
return server;

@@ -28,12 +31,15 @@ };

// tslint:disable-next-line:no-any
https.createServer = function createServer(options, callback) {
https.createServer = function createServer(options) {
var args = [];
for (var _i = 2; _i < arguments.length; _i++) {
args[_i - 2] = arguments[_i];
for (var _i = 1; _i < arguments.length; _i++) {
args[_i - 1] = arguments[_i];
}
var app = buildApp(callback);
var server = oldHttpsCreateServer.call.apply(oldHttpsCreateServer, [this, options, app].concat(args));
server.on('listening', function () {
glimpse_common_1.printBannerGreeting("https://localhost:" + server.address().port + "/glimpse/client");
});
var callback;
if (args.length && typeof args[0] === 'function') {
callback = args[0];
args.splice(0, 1);
}
// NOTE: The callback is not passed through to the old createServer() (as it's added later).
var server = oldHttpsCreateServer.call.apply(oldHttpsCreateServer, [this, options].concat(args));
patchServer(server, callback, 'https');
return server;

@@ -44,3 +50,3 @@ };

;
function buildApp(originalCallback) {
function buildApp() {
// NOTE: Express provides wrappers around http for starting the web server. If used,

@@ -56,18 +62,55 @@ // apps may not otherwise import http themselves. In that case, the only mechanism

var app = express();
app.use(function (req, res, next) {
/* eslint-disable camelcase */
req.__glimpse_inProcessServerRequest = true;
res.__glimpse_inProcessServerResponse = true;
/* eslint-enable camelcase */
next();
});
app.use('/glimpse', glimpse);
return function f(req, res) {
if (req.url.indexOf('/glimpse') === 0) {
/* eslint-disable camelcase */
req.__glimpse_inProcessServerRequest = true;
res.__glimpse_inProcessServerResponse = true;
/* eslint-enable camelcase */
return app(req, res);
return app;
}
;
function patchServerOn(server, app) {
var oldOn = server.on;
server.on = function glimpseServerOn(eventName, listener) {
var onArgs = [];
for (var _i = 2; _i < arguments.length; _i++) {
onArgs[_i - 2] = arguments[_i];
}
else {
return originalCallback(req, res);
if (eventName === 'request') {
var oldListener_1 = listener;
listener = function (req, res) {
var glimpseReq = req;
// Express `request` handlers will alter the `res.url`, so we maintain our own "original" URL...
if (!glimpseReq.__glimpse_originalUrl) {
glimpseReq.__glimpse_originalUrl = glimpseReq.url;
}
var isGlimpseEndpoint = glimpseReq.__glimpse_originalUrl.indexOf('/glimpse') === 0;
var isGlimpseEndpointHandler = oldListener_1 === app;
// Only invoke the listener:
// If it's the Glimpse listener *and* the request is for a Glimpse endpoint.
// - or -
// If it's not the Glimpse listener *and* the request is for an application (i.e. non-Glimpse) endpoint.
if ((isGlimpseEndpoint && isGlimpseEndpointHandler) || (!isGlimpseEndpoint && !isGlimpseEndpointHandler)) {
return oldListener_1(req, res);
}
};
}
return oldOn.call.apply(oldOn, [this, eventName, listener].concat(onArgs));
};
}
;
function patchServer(server, callback, protocol) {
var app = buildApp();
patchServerOn(server, app);
server.on('request', app);
// If specified, attach the callback originally passed to createServer()...
if (callback) {
server.on('request', callback);
}
server.on('listening', function () {
glimpse_common_1.printBannerGreeting(protocol + "://localhost:" + server.address().port + "/glimpse/client");
});
}
//# sourceMappingURL=../../../maps/src/hosting/host-express.js.map

@@ -8,3 +8,3 @@ 'use strict';

export function setupProxy() {
// Note: http.createServer and https.createServer have differnt signatures,
// Note: http.createServer and https.createServer have different signatures,
// so we do each one separately here to keep things simple, even if there is

@@ -14,8 +14,15 @@ // some duplicated code

// tslint:disable-next-line:no-any
(http as any).createServer = function createServer(callback, ...args) {
const app = buildApp(callback);
const server = oldHttpCreateServer.call(this, app, ...args);
server.on('listening', () => {
printBannerGreeting(`http://localhost:${server.address().port}/glimpse/client`);
});
(http as any).createServer = function createServer(...args) {
let callback;
if (args.length && typeof args[0] === 'function') {
callback = args[0];
args.splice(0, 1);
}
// NOTE: The callback is not passed through to the old createServer() (as it's added later).
const server = oldHttpCreateServer.apply(this, args);
patchServer(server, callback, 'http');
return server;

@@ -26,8 +33,15 @@ };

// tslint:disable-next-line:no-any
(https as any).createServer = function createServer(options, callback, ...args) {
const app = buildApp(callback);
const server = oldHttpsCreateServer.call(this, options, app, ...args);
server.on('listening', () => {
printBannerGreeting(`https://localhost:${server.address().port}/glimpse/client`);
});
(https as any).createServer = function createServer(options, ...args) {
let callback;
if (args.length && typeof args[0] === 'function') {
callback = args[0];
args.splice(0, 1);
}
// NOTE: The callback is not passed through to the old createServer() (as it's added later).
const server = oldHttpsCreateServer.call(this, options, ...args);
patchServer(server, callback, 'https');
return server;

@@ -37,3 +51,3 @@ };

function buildApp(originalCallback) {
function buildApp() {

@@ -53,16 +67,66 @@ // NOTE: Express provides wrappers around http for starting the web server. If used,

app.use((req, res, next) => {
/* eslint-disable camelcase */
req.__glimpse_inProcessServerRequest = true;
res.__glimpse_inProcessServerResponse = true;
/* eslint-enable camelcase */
next();
});
app.use('/glimpse', glimpse);
return function f(req, res) {
if (req.url.indexOf('/glimpse') === 0) {
/* eslint-disable camelcase */
req.__glimpse_inProcessServerRequest = true;
res.__glimpse_inProcessServerResponse = true;
/* eslint-enable camelcase */
return app(req, res);
return app;
};
interface IGlimpseListenedIncomingMessage extends http.IncomingMessage {
__glimpse_originalUrl: string | undefined;
}
function patchServerOn(server, app) {
const oldOn = server.on;
server.on = function glimpseServerOn(eventName: string, listener, ...onArgs) {
if (eventName === 'request') {
const oldListener = listener;
listener = (req, res) => {
const glimpseReq: IGlimpseListenedIncomingMessage = req;
// Express `request` handlers will alter the `res.url`, so we maintain our own "original" URL...
if (!glimpseReq.__glimpse_originalUrl) {
glimpseReq.__glimpse_originalUrl = glimpseReq.url;
}
const isGlimpseEndpoint = glimpseReq.__glimpse_originalUrl.indexOf('/glimpse') === 0;
const isGlimpseEndpointHandler = oldListener === app;
// Only invoke the listener:
// If it's the Glimpse listener *and* the request is for a Glimpse endpoint.
// - or -
// If it's not the Glimpse listener *and* the request is for an application (i.e. non-Glimpse) endpoint.
if ((isGlimpseEndpoint && isGlimpseEndpointHandler) || (!isGlimpseEndpoint && !isGlimpseEndpointHandler)) {
return oldListener(req, res);
}
};
}
else {
return originalCallback(req, res);
}
return oldOn.call(this, eventName, listener, ...onArgs);
};
};
}
function patchServer(server: http.Server, callback, protocol: string) {
const app = buildApp();
patchServerOn(server, app);
server.on('request', app);
// If specified, attach the callback originally passed to createServer()...
if (callback) {
server.on('request', callback);
}
server.on('listening', () => {
printBannerGreeting(`${protocol}://localhost:${server.address().port}/glimpse/client`);
});
}

@@ -21,4 +21,8 @@ import { IMessagePublisher } from './messaging/IMessagePublisher';

export interface IServerOptions {
}
export interface IServer {
providers: IProviders;
init(options?: IServerOptions): void;
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

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