node-curl-impersonate
Advanced tools
Comparing version 1.2.6 to 1.2.7
@@ -21,5 +21,5 @@ interface CurlImpersonateOptions { | ||
getRequest(flags: Array<string>, headers: string): Promise<string>; | ||
postRequest(flags: Array<string>, headers: string): Promise<string>; | ||
postRequest(flags: Array<string>, headers: string, body: Object | undefined): Promise<string>; | ||
convertHeaderObjectToCURL(): string; | ||
} | ||
export default CurlImpersonate; |
@@ -0,1 +1,8 @@ | ||
/* | ||
curl-impersonate by wearr. | ||
IF YOU PAID FOR THIS SOFTWARE, YOU HAVE BEEN SCAMMED! | ||
*/ | ||
import * as proc from "child_process"; | ||
@@ -11,3 +18,3 @@ import * as path from 'path'; | ||
makeRequest() { | ||
return new Promise(async (resolve, reject) => { | ||
return new Promise((resolve, reject) => { | ||
if (this.validateOptions(this.options)) { | ||
@@ -17,19 +24,20 @@ this.setProperBinary(); | ||
let flags = this.options.flags || []; | ||
if (this.options.followRedirects) { | ||
flags.push("-L"); | ||
if (this.options.method == "GET") { | ||
this.getRequest(flags, headers) | ||
.then(response => resolve(response)) | ||
.catch(error => reject(error)); | ||
} | ||
if (this.options.timeout) { | ||
flags.push(`--connect-timeout ${this.options.timeout / 1000}`); | ||
else if (this.options.method == "POST") { | ||
this.postRequest(flags, headers, this.options.body) | ||
.then(response => resolve(response)) | ||
.catch(error => reject(error)); | ||
} | ||
switch (this.options.method.toUpperCase()) { | ||
case "GET": | ||
resolve(await this.getRequest(flags, headers)); | ||
break; | ||
case "POST": | ||
resolve(await this.postRequest(flags, headers)); | ||
break; | ||
default: | ||
throw new Error("Invalid Method! Valid HTTP methods are " + this.validMethods); | ||
else { | ||
// Handle other HTTP methods if needed | ||
reject(new Error("Unsupported HTTP method")); | ||
} | ||
} | ||
else { | ||
reject(new Error("Invalid options")); | ||
} | ||
}); | ||
@@ -78,12 +86,14 @@ } | ||
async getRequest(flags, headers) { | ||
// GET REQUEST | ||
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(); | ||
return result.stdout.toString(); // Convert the stdout buffer to a string and return it | ||
} | ||
async postRequest(flags, headers) { | ||
async postRequest(flags, headers, body) { | ||
// POST REQUEST | ||
let binpath = path.join(__dirname, '..', 'bin', this.binary); | ||
let args = `${flags.join(' ')} ${headers} -d '${JSON.stringify(this.options.body)}' ${this.url}`; | ||
let args = `${flags.join(' ')} ${headers} -d '${JSON.stringify(body)}' ${this.url}`; | ||
const result = proc.spawnSync(`${binpath} ${args}`, { shell: true }); | ||
return result.stdout.toString(); | ||
return result.stdout.toString(); // Convert the stdout buffer to a string and return it | ||
} | ||
@@ -95,1 +105,2 @@ convertHeaderObjectToCURL() { | ||
export default CurlImpersonate; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "node-curl-impersonate", | ||
"version": "1.2.6", | ||
"version": "1.2.7", | ||
"description": "A wrapper around cURL-impersonate, a binary which can be used to bypass TLS fingerprinting.", | ||
@@ -8,3 +8,4 @@ "main": "dist/index.js", | ||
"scripts": { | ||
"build": "tsc" | ||
"build": "tsc", | ||
"test": "jest" | ||
}, | ||
@@ -20,4 +21,11 @@ "keywords": [ | ||
"devDependencies": { | ||
"@types/node": "^20.5.9" | ||
"@jest/globals": "^29.7.0", | ||
"@types/jest": "^29.5.5", | ||
"@types/node": "^20.5.9", | ||
"ts-jest": "^29.1.1" | ||
}, | ||
"dependencies": { | ||
"jest": "^29.7.0", | ||
"ts-node": "^10.9.1" | ||
} | ||
} |
@@ -34,2 +34,3 @@ /* | ||
followRedirects?: boolean | true; | ||
verbose?: boolean | false; | ||
} | ||
@@ -44,2 +45,9 @@ | ||
export interface CurlResponse { | ||
statusCode: number; | ||
response: string; | ||
responseHeaders: Object; | ||
requestHeaders: Object; | ||
} | ||
export class CurlImpersonate { | ||
@@ -54,28 +62,39 @@ constructor(url: string, options: CurlImpersonateOptions) { | ||
makeRequest() { | ||
// Convert code to be promise based | ||
return new Promise(async (resolve, reject) => { | ||
return new Promise((resolve, reject) => { | ||
if (this.validateOptions(this.options)) { | ||
this.setProperBinary() | ||
this.setProperBinary(); | ||
let headers = this.convertHeaderObjectToCURL(); | ||
let flags = this.options.flags || []; | ||
if (this.options.followRedirects) { | ||
flags.push("-L") | ||
if (this.options.method == "GET") { | ||
if (this.options.verbose) { | ||
console.log("GET REQUEST: " + this.url) | ||
} | ||
this.getRequest(flags, headers) | ||
.then(response => { | ||
if (this.options.verbose) { | ||
console.log("RESPONSE: " + response) | ||
} | ||
resolve(response); | ||
}) | ||
.catch(error => { | ||
if (this.options.verbose) { | ||
console.log("ERROR: " + error) | ||
} | ||
reject(error); | ||
}); | ||
} else if (this.options.method == "POST") { | ||
this.postRequest(flags, headers, this.options.body) | ||
.then(response => resolve(response)) | ||
.catch(error => reject(error)); | ||
} else { | ||
// Handle other HTTP methods if needed | ||
reject(new Error("Unsupported HTTP method")); | ||
} | ||
if (this.options.timeout) { | ||
flags.push(`--connect-timeout ${this.options.timeout / 1000}`) | ||
} | ||
switch (this.options.method.toUpperCase()) { | ||
case "GET": | ||
resolve(await this.getRequest(flags, headers)); | ||
break; | ||
case "POST": | ||
resolve(await this.postRequest(flags, headers)); | ||
break; | ||
default: | ||
throw new Error("Invalid Method! Valid HTTP methods are " + this.validMethods) | ||
} | ||
} | ||
}) | ||
} else { | ||
reject(new Error("Invalid options")); | ||
} | ||
}); | ||
} | ||
validateOptions(options: CurlImpersonateOptions) { | ||
@@ -124,6 +143,6 @@ if (this.validMethods.includes(options.method.toUpperCase())) { | ||
async postRequest(flags: Array<string>, headers: string) { | ||
async postRequest(flags: Array<string>, headers: string, body: Object | undefined) { | ||
// POST REQUEST | ||
let binpath = path.join(__dirname, '..', 'bin', this.binary); | ||
let args = `${flags.join(' ')} ${headers} -d '${JSON.stringify(this.options.body)}' ${this.url}`; | ||
let args = `${flags.join(' ')} ${headers} -d '${JSON.stringify(body)}' ${this.url}`; | ||
const result = proc.spawnSync(`${binpath} ${args}`, { shell: true }); | ||
@@ -130,0 +149,0 @@ return result.stdout.toString(); // Convert the stdout buffer to a string and return it |
{ | ||
"compilerOptions": { | ||
"target": "ESNext", | ||
"module": "ESNext", | ||
"target": "ES2020", | ||
"module": "ES2020", | ||
"rootDir": "./src", | ||
"moduleResolution": "node", | ||
"declaration": true, | ||
"sourceMap": true, | ||
"outDir": "dist", | ||
"esModuleInterop": true, | ||
"forceConsistentCasingInFileNames": true, | ||
"strict": true, | ||
"outDir": "./dist", | ||
"removeComments": true, | ||
"declaration": true, | ||
"lib": ["ESNext", "DOM", "DOM.Iterable"], | ||
} | ||
"skipLibCheck": true | ||
}, | ||
"ts-node": { | ||
"esm": true | ||
}, | ||
"exclude": ["tests", "jest.config.ts", "dist"], | ||
"lib": ["esnext"], | ||
"include": ["src"] | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
8845927
14
434
2
4
3
+ Addedjest@^29.7.0
+ Addedts-node@^10.9.1
+ Added@ampproject/remapping@2.3.0(transitive)
+ Added@babel/code-frame@7.26.2(transitive)
+ Added@babel/compat-data@7.26.2(transitive)
+ Added@babel/core@7.26.0(transitive)
+ Added@babel/generator@7.26.2(transitive)
+ Added@babel/helper-compilation-targets@7.25.9(transitive)
+ Added@babel/helper-module-imports@7.25.9(transitive)
+ Added@babel/helper-module-transforms@7.26.0(transitive)
+ Added@babel/helper-plugin-utils@7.25.9(transitive)
+ Added@babel/helper-string-parser@7.25.9(transitive)
+ Added@babel/helper-validator-identifier@7.25.9(transitive)
+ Added@babel/helper-validator-option@7.25.9(transitive)
+ Added@babel/helpers@7.26.0(transitive)
+ Added@babel/parser@7.26.2(transitive)
+ Added@babel/plugin-syntax-async-generators@7.8.4(transitive)
+ Added@babel/plugin-syntax-bigint@7.8.3(transitive)
+ Added@babel/plugin-syntax-class-properties@7.12.13(transitive)
+ Added@babel/plugin-syntax-class-static-block@7.14.5(transitive)
+ Added@babel/plugin-syntax-import-attributes@7.26.0(transitive)
+ Added@babel/plugin-syntax-import-meta@7.10.4(transitive)
+ Added@babel/plugin-syntax-json-strings@7.8.3(transitive)
+ Added@babel/plugin-syntax-jsx@7.25.9(transitive)
+ Added@babel/plugin-syntax-logical-assignment-operators@7.10.4(transitive)
+ Added@babel/plugin-syntax-nullish-coalescing-operator@7.8.3(transitive)
+ Added@babel/plugin-syntax-numeric-separator@7.10.4(transitive)
+ Added@babel/plugin-syntax-object-rest-spread@7.8.3(transitive)
+ Added@babel/plugin-syntax-optional-catch-binding@7.8.3(transitive)
+ Added@babel/plugin-syntax-optional-chaining@7.8.3(transitive)
+ Added@babel/plugin-syntax-private-property-in-object@7.14.5(transitive)
+ Added@babel/plugin-syntax-top-level-await@7.14.5(transitive)
+ Added@babel/plugin-syntax-typescript@7.25.9(transitive)
+ Added@babel/template@7.25.9(transitive)
+ Added@babel/traverse@7.25.9(transitive)
+ Added@babel/types@7.26.0(transitive)
+ Added@bcoe/v8-coverage@0.2.3(transitive)
+ Added@cspotcode/source-map-support@0.8.1(transitive)
+ Added@istanbuljs/load-nyc-config@1.1.0(transitive)
+ Added@istanbuljs/schema@0.1.3(transitive)
+ Added@jest/console@29.7.0(transitive)
+ Added@jest/core@29.7.0(transitive)
+ Added@jest/environment@29.7.0(transitive)
+ Added@jest/expect@29.7.0(transitive)
+ Added@jest/expect-utils@29.7.0(transitive)
+ Added@jest/fake-timers@29.7.0(transitive)
+ Added@jest/globals@29.7.0(transitive)
+ Added@jest/reporters@29.7.0(transitive)
+ Added@jest/schemas@29.6.3(transitive)
+ Added@jest/source-map@29.6.3(transitive)
+ Added@jest/test-result@29.7.0(transitive)
+ Added@jest/test-sequencer@29.7.0(transitive)
+ Added@jest/transform@29.7.0(transitive)
+ Added@jest/types@29.6.3(transitive)
+ Added@jridgewell/gen-mapping@0.3.5(transitive)
+ Added@jridgewell/resolve-uri@3.1.2(transitive)
+ Added@jridgewell/set-array@1.2.1(transitive)
+ Added@jridgewell/sourcemap-codec@1.5.0(transitive)
+ Added@jridgewell/trace-mapping@0.3.250.3.9(transitive)
+ Added@sinclair/typebox@0.27.8(transitive)
+ Added@sinonjs/commons@3.0.1(transitive)
+ Added@sinonjs/fake-timers@10.3.0(transitive)
+ Added@tsconfig/node10@1.0.11(transitive)
+ Added@tsconfig/node12@1.0.11(transitive)
+ Added@tsconfig/node14@1.0.3(transitive)
+ Added@tsconfig/node16@1.0.4(transitive)
+ Added@types/babel__core@7.20.5(transitive)
+ Added@types/babel__generator@7.6.8(transitive)
+ Added@types/babel__template@7.4.4(transitive)
+ Added@types/babel__traverse@7.20.6(transitive)
+ Added@types/graceful-fs@4.1.9(transitive)
+ Added@types/istanbul-lib-coverage@2.0.6(transitive)
+ Added@types/istanbul-lib-report@3.0.3(transitive)
+ Added@types/istanbul-reports@3.0.4(transitive)
+ Added@types/node@22.9.1(transitive)
+ Added@types/stack-utils@2.0.3(transitive)
+ Added@types/yargs@17.0.33(transitive)
+ Added@types/yargs-parser@21.0.3(transitive)
+ Addedacorn@8.14.0(transitive)
+ Addedacorn-walk@8.3.4(transitive)
+ Addedansi-escapes@4.3.2(transitive)
+ Addedansi-regex@5.0.1(transitive)
+ Addedansi-styles@4.3.05.2.0(transitive)
+ Addedanymatch@3.1.3(transitive)
+ Addedarg@4.1.3(transitive)
+ Addedargparse@1.0.10(transitive)
+ Addedbabel-jest@29.7.0(transitive)
+ Addedbabel-plugin-istanbul@6.1.1(transitive)
+ Addedbabel-plugin-jest-hoist@29.6.3(transitive)
+ Addedbabel-preset-current-node-syntax@1.1.0(transitive)
+ Addedbabel-preset-jest@29.6.3(transitive)
+ Addedbalanced-match@1.0.2(transitive)
+ Addedbrace-expansion@1.1.11(transitive)
+ Addedbraces@3.0.3(transitive)
+ Addedbrowserslist@4.24.2(transitive)
+ Addedbser@2.1.1(transitive)
+ Addedbuffer-from@1.1.2(transitive)
+ Addedcallsites@3.1.0(transitive)
+ Addedcamelcase@5.3.16.3.0(transitive)
+ Addedcaniuse-lite@1.0.30001683(transitive)
+ Addedchalk@4.1.2(transitive)
+ Addedchar-regex@1.0.2(transitive)
+ Addedci-info@3.9.0(transitive)
+ Addedcjs-module-lexer@1.4.1(transitive)
+ Addedcliui@8.0.1(transitive)
+ Addedco@4.6.0(transitive)
+ Addedcollect-v8-coverage@1.0.2(transitive)
+ Addedcolor-convert@2.0.1(transitive)
+ Addedcolor-name@1.1.4(transitive)
+ Addedconcat-map@0.0.1(transitive)
+ Addedconvert-source-map@2.0.0(transitive)
+ Addedcreate-jest@29.7.0(transitive)
+ Addedcreate-require@1.1.1(transitive)
+ Addedcross-spawn@7.0.6(transitive)
+ Addeddebug@4.3.7(transitive)
+ Addeddedent@1.5.3(transitive)
+ Addeddeepmerge@4.3.1(transitive)
+ Addeddetect-newline@3.1.0(transitive)
+ Addeddiff@4.0.2(transitive)
+ Addeddiff-sequences@29.6.3(transitive)
+ Addedelectron-to-chromium@1.5.64(transitive)
+ Addedemittery@0.13.1(transitive)
+ Addedemoji-regex@8.0.0(transitive)
+ Addederror-ex@1.3.2(transitive)
+ Addedescalade@3.2.0(transitive)
+ Addedescape-string-regexp@2.0.0(transitive)
+ Addedesprima@4.0.1(transitive)
+ Addedexeca@5.1.1(transitive)
+ Addedexit@0.1.2(transitive)
+ Addedexpect@29.7.0(transitive)
+ Addedfast-json-stable-stringify@2.1.0(transitive)
+ Addedfb-watchman@2.0.2(transitive)
+ Addedfill-range@7.1.1(transitive)
+ Addedfind-up@4.1.0(transitive)
+ Addedfs.realpath@1.0.0(transitive)
+ Addedfsevents@2.3.3(transitive)
+ Addedfunction-bind@1.1.2(transitive)
+ Addedgensync@1.0.0-beta.2(transitive)
+ Addedget-caller-file@2.0.5(transitive)
+ Addedget-package-type@0.1.0(transitive)
+ Addedget-stream@6.0.1(transitive)
+ Addedglob@7.2.3(transitive)
+ Addedglobals@11.12.0(transitive)
+ Addedgraceful-fs@4.2.11(transitive)
+ Addedhas-flag@4.0.0(transitive)
+ Addedhasown@2.0.2(transitive)
+ Addedhtml-escaper@2.0.2(transitive)
+ Addedhuman-signals@2.1.0(transitive)
+ Addedimport-local@3.2.0(transitive)
+ Addedimurmurhash@0.1.4(transitive)
+ Addedinflight@1.0.6(transitive)
+ Addedinherits@2.0.4(transitive)
+ Addedis-arrayish@0.2.1(transitive)
+ Addedis-core-module@2.15.1(transitive)
+ Addedis-fullwidth-code-point@3.0.0(transitive)
+ Addedis-generator-fn@2.1.0(transitive)
+ Addedis-number@7.0.0(transitive)
+ Addedis-stream@2.0.1(transitive)
+ Addedisexe@2.0.0(transitive)
+ Addedistanbul-lib-coverage@3.2.2(transitive)
+ Addedistanbul-lib-instrument@5.2.16.0.3(transitive)
+ Addedistanbul-lib-report@3.0.1(transitive)
+ Addedistanbul-lib-source-maps@4.0.1(transitive)
+ Addedistanbul-reports@3.1.7(transitive)
+ Addedjest@29.7.0(transitive)
+ Addedjest-changed-files@29.7.0(transitive)
+ Addedjest-circus@29.7.0(transitive)
+ Addedjest-cli@29.7.0(transitive)
+ Addedjest-config@29.7.0(transitive)
+ Addedjest-diff@29.7.0(transitive)
+ Addedjest-docblock@29.7.0(transitive)
+ Addedjest-each@29.7.0(transitive)
+ Addedjest-environment-node@29.7.0(transitive)
+ Addedjest-get-type@29.6.3(transitive)
+ Addedjest-haste-map@29.7.0(transitive)
+ Addedjest-leak-detector@29.7.0(transitive)
+ Addedjest-matcher-utils@29.7.0(transitive)
+ Addedjest-message-util@29.7.0(transitive)
+ Addedjest-mock@29.7.0(transitive)
+ Addedjest-pnp-resolver@1.2.3(transitive)
+ Addedjest-regex-util@29.6.3(transitive)
+ Addedjest-resolve@29.7.0(transitive)
+ Addedjest-resolve-dependencies@29.7.0(transitive)
+ Addedjest-runner@29.7.0(transitive)
+ Addedjest-runtime@29.7.0(transitive)
+ Addedjest-snapshot@29.7.0(transitive)
+ Addedjest-util@29.7.0(transitive)
+ Addedjest-validate@29.7.0(transitive)
+ Addedjest-watcher@29.7.0(transitive)
+ Addedjest-worker@29.7.0(transitive)
+ Addedjs-tokens@4.0.0(transitive)
+ Addedjs-yaml@3.14.1(transitive)
+ Addedjsesc@3.0.2(transitive)
+ Addedjson-parse-even-better-errors@2.3.1(transitive)
+ Addedjson5@2.2.3(transitive)
+ Addedkleur@3.0.3(transitive)
+ Addedleven@3.1.0(transitive)
+ Addedlines-and-columns@1.2.4(transitive)
+ Addedlocate-path@5.0.0(transitive)
+ Addedlru-cache@5.1.1(transitive)
+ Addedmake-dir@4.0.0(transitive)
+ Addedmake-error@1.3.6(transitive)
+ Addedmakeerror@1.0.12(transitive)
+ Addedmerge-stream@2.0.0(transitive)
+ Addedmicromatch@4.0.8(transitive)
+ Addedmimic-fn@2.1.0(transitive)
+ Addedminimatch@3.1.2(transitive)
+ Addedms@2.1.3(transitive)
+ Addednatural-compare@1.4.0(transitive)
+ Addednode-int64@0.4.0(transitive)
+ Addednode-releases@2.0.18(transitive)
+ Addednormalize-path@3.0.0(transitive)
+ Addednpm-run-path@4.0.1(transitive)
+ Addedonce@1.4.0(transitive)
+ Addedonetime@5.1.2(transitive)
+ Addedp-limit@2.3.03.1.0(transitive)
+ Addedp-locate@4.1.0(transitive)
+ Addedp-try@2.2.0(transitive)
+ Addedparse-json@5.2.0(transitive)
+ Addedpath-exists@4.0.0(transitive)
+ Addedpath-is-absolute@1.0.1(transitive)
+ Addedpath-key@3.1.1(transitive)
+ Addedpath-parse@1.0.7(transitive)
+ Addedpicocolors@1.1.1(transitive)
+ Addedpicomatch@2.3.1(transitive)
+ Addedpirates@4.0.6(transitive)
+ Addedpkg-dir@4.2.0(transitive)
+ Addedpretty-format@29.7.0(transitive)
+ Addedprompts@2.4.2(transitive)
+ Addedpure-rand@6.1.0(transitive)
+ Addedreact-is@18.3.1(transitive)
+ Addedrequire-directory@2.1.1(transitive)
+ Addedresolve@1.22.8(transitive)
+ Addedresolve-cwd@3.0.0(transitive)
+ Addedresolve-from@5.0.0(transitive)
+ Addedresolve.exports@2.0.2(transitive)
+ Addedsemver@6.3.17.6.3(transitive)
+ Addedshebang-command@2.0.0(transitive)
+ Addedshebang-regex@3.0.0(transitive)
+ Addedsignal-exit@3.0.7(transitive)
+ Addedsisteransi@1.0.5(transitive)
+ Addedslash@3.0.0(transitive)
+ Addedsource-map@0.6.1(transitive)
+ Addedsource-map-support@0.5.13(transitive)
+ Addedsprintf-js@1.0.3(transitive)
+ Addedstack-utils@2.0.6(transitive)
+ Addedstring-length@4.0.2(transitive)
+ Addedstring-width@4.2.3(transitive)
+ Addedstrip-ansi@6.0.1(transitive)
+ Addedstrip-bom@4.0.0(transitive)
+ Addedstrip-final-newline@2.0.0(transitive)
+ Addedstrip-json-comments@3.1.1(transitive)
+ Addedsupports-color@7.2.08.1.1(transitive)
+ Addedsupports-preserve-symlinks-flag@1.0.0(transitive)
+ Addedtest-exclude@6.0.0(transitive)
+ Addedtmpl@1.0.5(transitive)
+ Addedto-regex-range@5.0.1(transitive)
+ Addedts-node@10.9.2(transitive)
+ Addedtype-detect@4.0.8(transitive)
+ Addedtype-fest@0.21.3(transitive)
+ Addedtypescript@5.7.2(transitive)
+ Addedundici-types@6.19.8(transitive)
+ Addedupdate-browserslist-db@1.1.1(transitive)
+ Addedv8-compile-cache-lib@3.0.1(transitive)
+ Addedv8-to-istanbul@9.3.0(transitive)
+ Addedwalker@1.0.8(transitive)
+ Addedwhich@2.0.2(transitive)
+ Addedwrap-ansi@7.0.0(transitive)
+ Addedwrappy@1.0.2(transitive)
+ Addedwrite-file-atomic@4.0.2(transitive)
+ Addedy18n@5.0.8(transitive)
+ Addedyallist@3.1.1(transitive)
+ Addedyargs@17.7.2(transitive)
+ Addedyargs-parser@21.1.1(transitive)
+ Addedyn@3.1.1(transitive)
+ Addedyocto-queue@0.1.0(transitive)