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

puppeteer-page-proxy

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

puppeteer-page-proxy - npm Package Compare versions

Comparing version 1.2.0 to 1.2.2

README.md

5

changelog.md
# Change log
### [1.2.2] - 2020-02-09
#### Patches
- Fixed code indentation.
- Updated examples.
- Optimization.
### [1.2.0] - 2020-02-09

@@ -3,0 +8,0 @@ #### Major changes

4

package.json
{
"name": "puppeteer-page-proxy",
"description": "Additional Node.js module to use with 'puppeteer' for setting proxies per page basis.",
"version": "1.2.0",
"version": "1.2.2",
"author": "Cuadrix <cuadrix12000@gmail.com> (https://github.com/Cuadrix)",

@@ -26,3 +26,3 @@ "homepage": "https://github.com/Cuadrix/puppeteer-page-proxy",

"got": "^10.5.2",
"http-proxy-agent": "^4.0.0",
"http-proxy-agent": "^4.0.1",
"https-proxy-agent": "^5.0.0",

@@ -29,0 +29,0 @@ "socks-proxy-agent": "^5.0.0",

@@ -13,3 +13,3 @@ const {setHeaders, setAgent, request} = require("../lib/request");

let page, req;
if (param.constructor.name === "Request"){
if (param.constructor.name === "Request") {
req = param;

@@ -16,0 +16,0 @@ }

module.exports = class CDP {
static async Send(ws, command) {
ws.send(JSON.stringify(command));
return new Promise(resolve => {
ws.on("message", function handler(msg) {
const response = JSON.parse(msg);
if (response.id === command.id) {
ws.removeListener("message", handler);
resolve(response);
}
});
});
}
static Target = {
attachToTarget: async (ws, targetId) => {
const result = (await this.Send(ws, {
id: 1,
method: "Target.attachToTarget",
params: {
targetId: targetId,
flatten: true,
}
})).result;
if (result) {
return result.sessionId;
}
}
};
static Network = {
getCookies: async (ws, sessionId) => {
const result = (await this.Send(ws, {
sessionId,
id: 2,
method: "Network.getCookies"
})).result;
if (result) {
return result.cookies;
}
}
};
static async Send(ws, command) {
ws.send(JSON.stringify(command));
return new Promise(resolve => {
ws.on("message", function handler(msg) {
const response = JSON.parse(msg);
if (response.id === command.id) {
ws.removeListener("message", handler);
resolve(response);
}
});
});
}
static Target = {
attachToTarget: async (ws, targetId) => {
const result = (await this.Send(ws, {
id: 1,
method: "Target.attachToTarget",
params: {
targetId: targetId,
flatten: true,
}
})).result;
if (result) {
return result.sessionId;
}
}
};
static Network = {
getCookies: async (ws, sessionId) => {
const result = (await this.Send(ws, {
sessionId,
id: 2,
method: "Network.getCookies"
})).result;
if (result) {
return result.cookies;
}
}
};
}

@@ -27,6 +27,6 @@ const got = require("got");

return new SocksProxyAgent(proxy);
}
}
else if (url.startsWith("https")) {
return new HttpsProxyAgent(proxy);
} else {
} else {
return new HttpProxyAgent(proxy);

@@ -33,0 +33,0 @@ }

const url = require("url");
module.exports = (host) => {
const proxy = url.parse(host);
if (proxy.protocol == null
|| !(/^((https?)|(socks[45]?)):?$/i.test(proxy.protocol))
|| proxy.hostname == null || proxy.hostname.length == 0
|| proxy.port == null || proxy.port < 0 || proxy.port > 65535) {
throw new Error(`${host} -> Invalid proxy`);
}
const proxy = url.parse(host);
if (proxy.protocol == null
|| !(/^((https?)|(socks[45]?)):?$/i.test(proxy.protocol))
|| proxy.hostname == null || proxy.hostname.length == 0
|| proxy.port == null || proxy.port < 0 || proxy.port > 65535) {
throw new Error(`${host} -> Invalid proxy`);
}
};
module.exports = (...args) => {
let types = [
"undefined", "object", "boolean", "number", "bigint", "string", "symbol", "function"
];
args.forEach((arg, index) => {
if (arg.length < 2) {
throw new Error("Too few arguments passed into the list");
} else if (arg.length > 3) {
throw new Error("Too many arguments passed into the list");
} else {
if (types.includes(arg[1])) {
if (typeof arg[0] != arg[1]) {
if (typeof arg[2] == "string" && arg[2].length > 0) {
throw new TypeError(`@arg${index + 1}: ${arg[2]}`);
} else {
throw new TypeError(`@arg${index + 1}: Type: ${typeof arg[0]} -> expected ${arg[1]}`);
}
}
} else {
throw new Error(`@arg${index + 1}: '${arg[1]}' is not a valid data type`);
}
}
});
let types = [
"undefined", "object", "boolean", "number", "bigint", "string", "symbol", "function"
];
args.forEach((arg, index) => {
if (arg.length < 2) {
throw new Error("Too few arguments passed into the list");
} else if (arg.length > 3) {
throw new Error("Too many arguments passed into the list");
} else {
if (types.includes(arg[1])) {
if (typeof arg[0] != arg[1]) {
if (typeof arg[2] == "string" && arg[2].length > 0) {
throw new TypeError(`@arg${index + 1}: ${arg[2]}`);
} else {
throw new TypeError(`@arg${index + 1}: Type: ${typeof arg[0]} -> expected ${arg[1]}`);
}
}
} else {
throw new Error(`@arg${index + 1}: '${arg[1]}' is not a valid data type`);
}
}
});
};
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