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

@applitools/execution-grid-client

Package Overview
Dependencies
Maintainers
30
Versions
47
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@applitools/execution-grid-client - npm Package Compare versions

Comparing version 1.1.1 to 1.1.2

40

dist/proxy-server.js

@@ -45,11 +45,15 @@ "use strict";

const server = (0, http_1.createServer)(async (request, response) => {
const requestLogger = logger.extend({
tags: { signature: `[${request.method}]${request.url}`, requestId: utils.general.guid() },
});
try {
if (request.method === 'POST' && /^\/session\/?$/.test(request.url)) {
return await handleNewSession(request, response);
return await handleNewSession({ request, response, logger: requestLogger });
}
else if (request.method === 'DELETE' && /^\/session\/[^\/]+\/?$/.test(request.url)) {
return await handleStopSession(request, response);
return await handleStopSession({ request, response, logger: requestLogger });
}
else {
return (0, proxy_1.proxy)(request, response, { target: forwardingUrl, forward: true });
requestLogger.log('Passthrough request');
return (0, proxy_1.proxy)(request, response, { target: forwardingUrl });
}

@@ -76,12 +80,9 @@ }

});
async function handleNewSession(request, response) {
async function handleNewSession({ request, response, logger, }) {
var _a, _b, _c, _d, _e, _f, _g;
const session = {};
const requestLogger = logger.extend({
tags: { signature: `[${request.method}]${request.url}`, requestId: utils.general.guid() },
});
const requestBody = await (0, raw_body_1.default)(request, 'utf-8').then(body => (body ? JSON.parse(body) : undefined));
if (!requestBody)
return requestLogger.log(`Request has no body`);
requestLogger.log(`Request was intercepted with body:`, requestBody);
return logger.log(`Request has no body`);
logger.log(`Request was intercepted with body:`, requestBody);
const capabilities = (_b = (_a = requestBody.capabilities) === null || _a === void 0 ? void 0 : _a.alwaysMatch) !== null && _b !== void 0 ? _b : requestBody.desiredCapabilities;

@@ -93,12 +94,12 @@ session.serverUrl = capabilities['applitools:eyesServerUrl'] = (_c = capabilities['applitools:eyesServerUrl']) !== null && _c !== void 0 ? _c : serverUrl;

}
requestLogger.log('Request body has modified:', requestBody);
logger.log('Request body has modified:', requestBody);
let attempt = 0;
while (true) {
const proxyResponse = await (0, proxy_1.proxy)(request, response, { target: forwardingUrl, body: requestBody });
const proxyResponse = await (0, proxy_1.proxy)(request, response, { target: forwardingUrl, body: requestBody, handle: true });
const responseBody = await (0, raw_body_1.default)(proxyResponse, 'utf-8').then(body => (body ? JSON.parse(body) : undefined));
if (!responseBody) {
response.writeHead(proxyResponse.statusCode, proxyResponse.headers).end();
return requestLogger.log(`Response has no body`);
return logger.log(`Response has no body`);
}
requestLogger.log(`Response was intercepted with body:`, responseBody);
logger.log(`Response was intercepted with body:`, responseBody);
if (!RETRY_ERROR_CODES.includes((_f = (_e = responseBody.value) === null || _e === void 0 ? void 0 : _e.data) === null || _f === void 0 ? void 0 : _f.appliErrorCode)) {

@@ -113,16 +114,13 @@ if ((_g = responseBody.value) === null || _g === void 0 ? void 0 : _g.sessionId)

request.removeAllListeners();
requestLogger.log(`Retrying sending the request (attempt ${attempt})`);
logger.log(`Retrying sending the request (attempt ${attempt})`);
}
}
async function handleStopSession(request, response) {
const requestLogger = logger.extend({
tags: { signature: `[${request.method}]${request.url}`, requestId: utils.general.guid() },
});
async function handleStopSession({ request, response, logger, }) {
const sessionId = request.url.split('/').pop();
requestLogger.log(`Request was intercepted with sessionId:`, sessionId);
const proxyResponse = await (0, proxy_1.proxy)(request, response, { target: forwardingUrl });
logger.log(`Request was intercepted with sessionId:`, sessionId);
const proxyResponse = await (0, proxy_1.proxy)(request, response, { target: forwardingUrl, handle: true });
const session = sessions.get(sessionId);
if (session.tunnelId) {
await deleteTunnel(session);
requestLogger.log(`Tunnel with id ${session.tunnelId} was deleted for session with id ${sessionId}`);
logger.log(`Tunnel with id ${session.tunnelId} was deleted for session with id ${sessionId}`);
}

@@ -129,0 +127,0 @@ sessions.delete(sessionId);

@@ -11,4 +11,4 @@ "use strict";

const settings = {
[options.forward ? 'forward' : 'target']: options.target,
selfHandleResponse: !options.forward,
target: options.target,
selfHandleResponse: options.handle,
ws: true,

@@ -15,0 +15,0 @@ changeOrigin: true,

{
"name": "@applitools/execution-grid-client",
"version": "1.1.1",
"version": "1.1.2",
"description": "",

@@ -5,0 +5,0 @@ "license": "SEE LICENSE IN LICENSE",

@@ -5,3 +5,3 @@ /// <reference types="node" />

target: string;
forward?: boolean;
handle?: boolean;
body?: Record<string, any>;

@@ -8,0 +8,0 @@ headers?: Record<string, string>;

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