2captcha
Advanced tools
Comparing version 3.0.6 to 3.0.7
@@ -175,2 +175,17 @@ interface BaseSolve { | ||
/** | ||
* Solves a CloudFlare (turnstile) captcha | ||
* @param publicKey The turnstile Site Key | ||
* @param pageurl The URL to the website the captcha is seen on | ||
* @param serviceURL The FunCaptcha Service URL (recommended) | ||
* @param extra Extra properties to pass to 2captcha | ||
* | ||
* @returns {Promise<CaptchaAnswer>} The result from the solve | ||
* @throws APIError | ||
* turnstile("0x4AAAAAAADIkEVyoXXXXXXX", "http://mysite.com/page/with/turnstile/") | ||
* .then((res) => { | ||
* console.log(res) | ||
* }) | ||
*/ | ||
turnstile(siteKey: string, pageURL: string, extra?: UserHCaptchaExtra): Promise<CaptchaAnswer>; | ||
/** | ||
* Reports a captcha as correctly solved. | ||
@@ -177,0 +192,0 @@ * |
@@ -320,2 +320,40 @@ "use strict"; | ||
/** | ||
* Solves a CloudFlare (turnstile) captcha | ||
* @param publicKey The turnstile Site Key | ||
* @param pageurl The URL to the website the captcha is seen on | ||
* @param serviceURL The FunCaptcha Service URL (recommended) | ||
* @param extra Extra properties to pass to 2captcha | ||
* | ||
* @returns {Promise<CaptchaAnswer>} The result from the solve | ||
* @throws APIError | ||
* turnstile("0x4AAAAAAADIkEVyoXXXXXXX", "http://mysite.com/page/with/turnstile/") | ||
* .then((res) => { | ||
* console.log(res) | ||
* }) | ||
*/ | ||
async turnstile(siteKey, pageURL, extra = {}) { | ||
const payload = { | ||
...extra, | ||
...this.defaultPayload, | ||
method: "turnstile", | ||
sitekey: siteKey, | ||
pageurl: pageURL, | ||
}; | ||
const response = await (0, fetch_1.default)(this.in + utils.objectToURI(payload)); | ||
const result = await response.text(); | ||
let data; | ||
try { | ||
data = JSON.parse(result); | ||
} | ||
catch { | ||
throw new _2captchaError_1.APIError(result); | ||
} | ||
if (data.status == 1) { | ||
return this.pollResponse(data.request); | ||
} | ||
else { | ||
throw new _2captchaError_1.APIError(data.request); | ||
} | ||
} | ||
/** | ||
* Reports a captcha as correctly solved. | ||
@@ -322,0 +360,0 @@ * |
{ | ||
"name": "2captcha", | ||
"version": "3.0.6", | ||
"version": "3.0.7", | ||
"main": "dist/index.js", | ||
@@ -5,0 +5,0 @@ "repository": "https://github.com/furry/2captcha", |
Sorry, the diff of this file is not supported yet
50895
1118