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

@spotlightjs/sidecar

Package Overview
Dependencies
Maintainers
0
Versions
40
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@spotlightjs/sidecar - npm Package Compare versions

Comparing version 1.6.2 to 1.7.0

31

dist/main.js

@@ -239,3 +239,3 @@ var __defProp = Object.defineProperty;

function enableCORS(handler) {
return function corsMiddleware(req, res) {
return function corsMiddleware(req, res, pathname, searchParams) {
const headers = {

@@ -255,3 +255,3 @@ ...getCorsHeader(),

}
return handler(req, res);
return handler(req, res, pathname, searchParams);
};

@@ -265,4 +265,4 @@ }

function streamRequestHandler(buffer2, incomingPayload) {
return function handleStreamRequest(req, res) {
if (req.method === "GET" && req.headers.accept && req.headers.accept == "text/event-stream") {
return function handleStreamRequest(req, res, pathname, searchParams) {
if (req.method === "GET" && req.headers.accept && req.headers.accept == "text/event-stream" && pathname === "/stream") {
res.writeHead(200, {

@@ -306,7 +306,15 @@ "Content-Type": "text/event-stream",

stream.on("end", () => {
buffer2.put([`${req.headers["content-type"]}`, body]);
var _a, _b;
let contentType = (_a = req.headers["content-type"]) == null ? void 0 : _a.split(";")[0].toLocaleLowerCase();
if (((_b = searchParams == null ? void 0 : searchParams.get("sentry_client")) == null ? void 0 : _b.startsWith("sentry.javascript.browser")) && req.headers.origin) {
contentType = "application/x-sentry-envelope";
}
if (!contentType) {
logger.warn("No content type, skipping payload...");
} else {
buffer2.put([contentType, body]);
}
if (process.env.SPOTLIGHT_CAPTURE || incomingPayload) {
const timestamp = (/* @__PURE__ */ new Date()).getTime();
const contentType = `${req.headers["content-type"]}`;
const filename = `${contentType.replace(/[^a-z0-9]/gi, "_").toLowerCase()}-${timestamp}.txt`;
const filename = `${(contentType == null ? void 0 : contentType.replace(/[^a-z0-9]/gi, "_")) || "no_content_type"}-${timestamp}.txt`;
if (incomingPayload) {

@@ -331,4 +339,4 @@ incomingPayload(body);

function fileServer(basePath) {
return function serveFile(req, res) {
let filePath = "." + req.url;
return function serveFile(req, res, pathname) {
let filePath = "." + (pathname || req.url);
if (filePath == "./") {

@@ -428,7 +436,8 @@ filePath = "./src/index.html";

}
const route = ROUTES.find((route2) => route2[0].test(url));
const { pathname, searchParams } = new URL(url, "http://" + (req.headers.host || "localhost"));
const route = ROUTES.find((route2) => route2[0].test(pathname));
if (!route) {
return error404(req, res);
}
return route[1](req, res);
return route[1](req, res, pathname, searchParams);
});

@@ -435,0 +444,0 @@ server.on("error", handleServerError);

{
"name": "@spotlightjs/sidecar",
"description": "A small proxy server to capture and forward data from backend services to Spotlight.",
"version": "1.6.2",
"version": "1.7.0",
"license": "Apache-2.0",

@@ -6,0 +6,0 @@ "type": "module",

@@ -47,3 +47,8 @@ import launchEditor from 'launch-editor';

type RequestHandler = (req: IncomingMessage, res: ServerResponse) => void;
type RequestHandler = (
req: IncomingMessage,
res: ServerResponse,
pathname?: string,
searchParams?: URLSearchParams,
) => void;

@@ -60,3 +65,8 @@ function getCorsHeader(): { [name: string]: string } {

function enableCORS(handler: RequestHandler): RequestHandler {
return function corsMiddleware(req: IncomingMessage, res: ServerResponse) {
return function corsMiddleware(
req: IncomingMessage,
res: ServerResponse,
pathname?: string,
searchParams?: URLSearchParams,
) {
const headers = {

@@ -76,3 +86,3 @@ ...getCorsHeader(),

}
return handler(req, res);
return handler(req, res, pathname, searchParams);
};

@@ -88,4 +98,14 @@ }

function streamRequestHandler(buffer: MessageBuffer<Payload>, incomingPayload?: IncomingPayloadCallback) {
return function handleStreamRequest(req: IncomingMessage, res: ServerResponse): void {
if (req.method === 'GET' && req.headers.accept && req.headers.accept == 'text/event-stream') {
return function handleStreamRequest(
req: IncomingMessage,
res: ServerResponse,
pathname?: string,
searchParams?: URLSearchParams,
): void {
if (
req.method === 'GET' &&
req.headers.accept &&
req.headers.accept == 'text/event-stream' &&
pathname === '/stream'
) {
res.writeHead(200, {

@@ -139,8 +159,16 @@ 'Content-Type': 'text/event-stream',

stream.on('end', () => {
buffer.put([`${req.headers['content-type']}`, body]);
let contentType = req.headers['content-type']?.split(';')[0].toLocaleLowerCase();
if (searchParams?.get('sentry_client')?.startsWith('sentry.javascript.browser') && req.headers.origin) {
// This is a correction we make as Sentry Browser SDK may send messages with text/plain to avoid CORS issues
contentType = 'application/x-sentry-envelope';
}
if (!contentType) {
logger.warn('No content type, skipping payload...');
} else {
buffer.put([contentType, body]);
}
if (process.env.SPOTLIGHT_CAPTURE || incomingPayload) {
const timestamp = new Date().getTime();
const contentType = `${req.headers['content-type']}`;
const filename = `${contentType.replace(/[^a-z0-9]/gi, '_').toLowerCase()}-${timestamp}.txt`;
const filename = `${contentType?.replace(/[^a-z0-9]/gi, '_') || 'no_content_type'}-${timestamp}.txt`;

@@ -168,4 +196,4 @@ if (incomingPayload) {

function fileServer(basePath: string) {
return function serveFile(req: IncomingMessage, res: ServerResponse): void {
let filePath = '.' + req.url;
return function serveFile(req: IncomingMessage, res: ServerResponse, pathname?: string): void {
let filePath = '.' + (pathname || req.url);
if (filePath == './') {

@@ -283,7 +311,8 @@ filePath = './src/index.html';

const route = ROUTES.find(route => route[0].test(url));
const { pathname, searchParams } = new URL(url, 'http://' + (req.headers.host || 'localhost'));
const route = ROUTES.find(route => route[0].test(pathname));
if (!route) {
return error404(req, res);
}
return route[1](req, res);
return route[1](req, res, pathname, searchParams);
});

@@ -290,0 +319,0 @@

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