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

node-curl-impersonate

Package Overview
Dependencies
Maintainers
1
Versions
38
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-curl-impersonate - npm Package Compare versions

Comparing version 1.0.7 to 1.0.8

6

dist/index.d.ts

@@ -17,9 +17,9 @@ interface CurlImpersonateOptions {

constructor(url: string, options: CurlImpersonateOptions);
makeRequest(): void;
makeRequest(): string | undefined;
validateOptions(options: CurlImpersonateOptions): boolean;
setProperBinary(): void;
getRequest(flags: Array<string>, headers: string): void;
postRequest(flags: Array<string>, headers: string): void;
getRequest(flags: Array<string>, headers: string): string;
postRequest(flags: Array<string>, headers: string): string;
convertHeaderObjectToCURL(): string;
}
export default CurlImpersonate;

@@ -15,8 +15,15 @@ import * as proc from "child_process";

let flags = this.options.flags || [];
if (this.options.followRedirects) {
flags.push("-L");
}
if (this.options.timeout) {
flags.push(`--connect-timeout ${this.options.timeout / 1000}`);
}
switch (this.options.method.toUpperCase()) {
case "GET":
this.getRequest(flags, headers);
break;
return this.getRequest(flags, headers);
case "POST":
this.postRequest(flags, headers);
return this.postRequest(flags, headers);
default:
throw new Error("Invalid Method! Valid HTTP methods are " + this.validMethods);
}

@@ -66,22 +73,12 @@ }

getRequest(flags, headers) {
if (this.options.followRedirects) {
flags.push("-L");
}
if (this.options.timeout) {
flags.push(`--connect-timeout ${this.options.timeout / 1000}`);
}
let binpath = path.join(__dirname, "..", "bin", this.binary);
let args = `${flags.join(" ")} ${headers} ${this.url}`;
proc.spawn(`${binpath} ${args}`, { shell: true, stdio: "inherit" });
let binpath = path.join(__dirname, '..', 'bin', this.binary);
let args = `${flags.join(' ')} ${headers} ${this.url}`;
const result = proc.spawnSync(`${binpath} ${args}`, { shell: true });
return result.stdout.toString();
}
postRequest(flags, headers) {
if (this.options.followRedirects) {
flags.push("-L");
}
if (this.options.timeout) {
flags.push(`--connect-timeout ${this.options.timeout / 1000}`);
}
let binpath = path.join(__dirname, "..", "bin", this.binary);
let args = `${flags.join(" ")} ${headers} -d '${JSON.stringify(this.options.body)}' ${this.url}`;
proc.spawn(`${binpath} ${args}`, { shell: true, stdio: "inherit" });
let binpath = path.join(__dirname, '..', 'bin', this.binary);
let args = `${flags.join(' ')} ${headers} -d '${JSON.stringify(this.options.body)}' ${this.url}`;
const result = proc.spawnSync(`${binpath} ${args}`, { shell: true });
return result.stdout.toString();
}

@@ -88,0 +85,0 @@ convertHeaderObjectToCURL() {

{
"name": "node-curl-impersonate",
"version": "1.0.7",
"version": "1.0.8",
"description": "A wrapper around cURL-impersonate, a binary which can be used to bypass TLS fingerprinting.",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

@@ -64,7 +64,5 @@ /*

case "GET":
this.getRequest(flags, headers);
break;
return this.getRequest(flags, headers);
case "POST":
this.postRequest(flags, headers);
break;
return this.postRequest(flags, headers);
default:

@@ -112,12 +110,16 @@ throw new Error("Invalid Method! Valid HTTP methods are " + this.validMethods)

// GET REQUEST
let binpath = path.join(__dirname, "..", "bin", this.binary)
let args = `${flags.join(" ")} ${headers} ${this.url}`
proc.spawn(`${binpath} ${args}`, { shell: true, stdio: "inherit" })
let binpath = path.join(__dirname, '..', 'bin', this.binary);
let args = `${flags.join(' ')} ${headers} ${this.url}`;
const result = proc.spawnSync(`${binpath} ${args}`, { shell: true });
return result.stdout.toString(); // Convert the stdout buffer to a string and return it
}
postRequest(flags: Array<string>, headers: string) {
// POST REQUEST
let binpath = path.join(__dirname, "..", "bin", this.binary)
let args = `${flags.join(" ")} ${headers} -d '${JSON.stringify(this.options.body)}' ${this.url}`
proc.spawn(`${binpath} ${args}`, { shell: true, stdio: "inherit" })
let binpath = path.join(__dirname, '..', 'bin', this.binary);
let args = `${flags.join(' ')} ${headers} -d '${JSON.stringify(this.options.body)}' ${this.url}`;
const result = proc.spawnSync(`${binpath} ${args}`, { shell: true });
return result.stdout.toString(); // Convert the stdout buffer to a string and return it
}
convertHeaderObjectToCURL() {

@@ -124,0 +126,0 @@ return Object.entries(this.options.headers).map(([key, value]) => `-H '${key}: ${value}'`).join(' ');

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