diff --git a/README.md b/README.md
index c792fc6..5b6a629 100644
--- a/README.md
+++ b/README.md
@@ -9,15 +9,15 @@
# JavaScript module for 2Captcha API (captcha solver)
-The easiest way to quickly integrate the [2Captcha](https://2captcha.com/) captcha-solving service into your code and automate the solving of any type of captcha.
-Examples of API requests for different captcha types are available on the [JavaScript captcha solver](https://2captcha.com/lang/javascript) page.
+The easiest way to quickly integrate the [2Captcha] captcha-solving service into your code and automate the solving of any type of captcha.
+Examples of API requests for different captcha types are available on the [JavaScript captcha solver] page.
- [JavaScript module for 2Captcha API (captcha solver)](#javascript-module-for-2captcha-api-captcha-solver)
- [Installation](#installation)
- [Configuration](#configuration)
- [TwoCaptcha instance options](#twocaptcha-instance-options)
- [Solve captcha](#solve-captcha)
- - [Image captchas](#image-captcha)
+ - [Image Captcha](#image-captcha)
- [reCAPTCHA v2](#recaptcha-v2)
- [reCAPTCHA v3](#recaptcha-v3)
- [hCaptcha](#hcaptcha)
@@ -36,6 +36,14 @@ Examples of API requests for different captcha types are available on the [JavaS
- [Friendly Captcha](#friendly-captcha)
- [Bounding Box Method](#bounding-box-method)
- [Grid](#grid)
+ - [Text Captcha](#text-captcha)
+ - [Canvas](#canvas)
+ - [Rotate](#rotate)
+ - [KeyCaptcha](#keycaptcha)
+ - [Cutcaptcha](#cutcaptcha)
+ - [Tencent](#tencent)
+ - [atbCAPTCHA](#atbcaptcha)
+ - [Audio Captcha](#audio-captcha)
- [Other methods](#other-methods)
- [goodReport](#goodreport)
- [badReport](#badreport)
@@ -43,9 +51,11 @@ Examples of API requests for different captcha types are available on the [JavaS
- [Proxies](#proxies)
- [Examples](#examples)
- [Examples using Puppeteer](#examples-using-puppeteer)
- - [Useful articles](#useful-articles)
+- [Useful articles](#useful-articles)
- [Get in touch](#get-in-touch)
- [Join the team 馃應](#join-the-team-)
+- [License](#license)
+ - [Graphics and Trademarks](#graphics-and-trademarks)
## Installation
@@ -109,7 +119,6 @@ Below you can find basic examples for every captcha type, check out the code bel
To bypass a normal captcha (distorted text on an image) use the following method. This method can also be used to recognize any text in an image.
```js
-// Read from a file as base64 text
const imageBase64 = fs.readFileSync("./examples/media/imageCaptcha_6e584.png", "base64")
solver.imageCaptcha({
@@ -119,7 +128,6 @@ solver.imageCaptcha({
max_len: 5
})
.then((res) => {
- // Logs the image text
console.log(res);
})
.catch((err) => {
@@ -498,6 +506,164 @@ solver.grid({
})
```
+### Text Captcha
+
+[API method description.](https://2captcha.com/2captcha-api#solving_text_captcha)
+
+This method can be used to bypass a captcha that requires answering a question provided in clear text.
+
+```js
+solver.textCaptcha({
+ textcaptcha: "If tomorrow is Saturday, what day is today?",
+ lang: 'en'
+})
+.then((res) => {
+ console.log(res);
+})
+.catch((err) => {
+ console.log(err);
+})
+```
+
+### Canvas
+
+[API method description.](https://2captcha.com/2captcha-api#canvas)
+
+The canvas method can be used when you need to draw a line around an object on an image. Returns a set of points' coordinates to draw a polygon.
+
+```js
+solver.canvas({
+ body: 'iVBORw0KGgoAAAANSgAAAcIA...',
+ imginstructions: '/9j/4AAQSkZJRgABAQEA...',
+ textinstructions: 'Highlight the red CIRCLE'
+})
+.then((res) => {
+ console.log(res);
+})
+.catch((err) => {
+ console.log(err);
+})
+```
+
+### Rotate
+
+[API method description.](https://2captcha.com/2captcha-api#solving_rotatecaptcha)
+
+This method can be used to solve a captcha that asks to rotate an object. It is mostly used to bypass FunCaptcha. Returns the rotation angle.
+
+```js
+solver.rotate({
+ body: imageBase64,
+ textinstructions: "Rotate the object to the correct position"
+})
+.then((res) => {
+ console.log(res);
+})
+.catch((err) => {
+ console.log(err);
+})
+```
+
+### KeyCaptcha
+
+[API method description.](https://2captcha.com/2captcha-api#solving_keycaptcha)
+
+Token-based method to solve KeyCaptcha.
+
+```js
+solver.keyCaptcha({
+ pageurl: "https://2captcha.com/demo/keycaptcha",
+ userId: '184015',
+ sessionId: '0917788cad24ad3a69813c4fcd556061',
+ webServerSign: '02f7f9669f1269595c4c69bcd4a3c52e',
+ webServerSign2: 'd888700f6f324ec0f32b44c32c50bde1'
+})
+.then((res) => {
+ console.log(res);
+})
+.catch((err) => {
+ console.log(err);
+})
+```
+
+### Cutcaptcha
+
+[API method description.](https://2captcha.com/2captcha-api#cutcaptcha)
+
+Use this method to solve Cutcaptcha. Returns the response in JSON.
+
+```js
+solver.cutCaptcha({
+ pageurl: "https://mysite.com/page/with/cutcaptcha",
+ misery_key: "098e6a849af406142e3150dbf4e6d0538db2b51f",
+ api_key: "SAs61IAI",
+})
+.then((res) => {
+console.log(res);
+})
+.catch((err) => {
+console.log(err);
+})
+```
+
+### Tencent
+
+[API method description.](https://2captcha.com/2captcha-api#tencent)
+
+Use this method to solve Tencent captcha. Returns the response in JSON.
+
+```js
+solver.tencent({
+ pageurl: "https://mysite.com/page/with/tencent",
+ appId: "189956587"
+})
+.then((res) => {
+console.log(res);
+})
+.catch((err) => {
+console.log(err);
+})
+```
+
+### atbCAPTCHA
+
+[API method description.](https://2captcha.com/2captcha-api#atb-captcha)
+
+Use this method to solve atbCAPTCHA challenge. Returns a token to bypass the captcha.
+
+```js
+solver.atbCaptcha({
+ pageurl: "https://mysite.com/page/with/atbCAPTCHA",
+ appId: "af25e409b33d722a95e56a230ff8771c",
+ apiServer: "https://cap.aisecurius.com"
+})
+.then((res) => {
+console.log(res);
+})
+.catch((err) => {
+console.log(err);
+})
+```
+
+### Audio Captcha
+
+[API method description.](https://2captcha.com/2captcha-api#audio-recognition)
+
+Use the following method to bypass an audio captcha (`mp3` formats only). You must provide the language as `lang = 'en'`. Supported languages are "en", "ru", "de", "el", "pt", "fr".
+
+```js
+solver.audio({
+ body: "SUQzBAAAAAAAHFRTU0UAAAA...",
+ lang: "en"
+})
+.then((res) => {
+ console.log(res);
+})
+.catch((err) => {
+ console.log(err);
+})
+```
+
## Other methods
### goodReport
@@ -558,6 +724,7 @@ At the moment we have implemented examples of bypassing Cloudflare Challenge pag
Links:
- [Cloudflare Bypassing Demo using Puppeteer](https://github.com/2captcha/cloudflare-demo)
- [Solving reCAPTCHA V2 using Puppeteer and clicks](https://github.com/2captcha/puppeteer-recaptcha-solver-using-clicks)
+- [Custom Slider Captcha Demo](https://github.com/2captcha/custom-slider-demo)
## Useful articles
@@ -565,8 +732,6 @@ Links:
* [Bypassing Cloudflare Challenge with Puppeteer and 2Captcha](https://2captcha.com/blog/bypassing-cloudflare-challenge-with-puppeteer-and-2captcha)
* [How to bypass Geetest v4 CAPTCHA](https://2captcha.com/blog/geetest-v4-support)
* [Automatic reCAPTCHA V3 resolution - a tutorial for developers and customers](https://2captcha.com/blog/recaptcha-v3-automatic-resolution)
-* [Custom Slider Captcha Demo](https://github.com/2captcha/custom-slider-demo)
-* [Cloudflare Challenge page bypass code example](https://github.com/2captcha/cloudflare-demo)
## Get in touch
@@ -579,7 +744,17 @@ There are many ways to contribute, of which development is only one! Find your n
+## License
+
+The code in this repository is licensed under the MIT License. See the [LICENSE](./LICENSE) file for more details.
+
+### Graphics and Trademarks
+
+The graphics and trademarks included in this repository are not covered by the MIT License. Please contact support for permissions regarding the use of these materials.
+
+[2Captcha]: https://2captcha.com/
+[JavaScript captcha solver]: https://2captcha.com/lang/javascript
[post options]: https://2captcha.com/2captcha-api#normal_post
[list of supported languages]: https://2captcha.com/2captcha-api#language
[Buy residential proxies]: https://2captcha.com/proxy/residential-proxies
diff --git a/examples/atbcaptcha.js b/examples/atbcaptcha.js
new file mode 100644
index 0000000..fc8a967
--- /dev/null
+++ b/examples/atbcaptcha.js
@@ -0,0 +1,16 @@
+const TwoCaptcha = require("../dist/index.js");
+require('dotenv').config();
+const APIKEY = process.env.APIKEY
+const solver = new TwoCaptcha.Solver(APIKEY);
+
+solver.atbCaptcha({
+ pageurl: "https://mysite.com/page/with/atbCAPTCHA",
+ appId: "af25e409b33d722a95e56a230ff8771c",
+ apiServer: "https://cap.aisecurius.com"
+})
+.then((res) => {
+ console.log(res);
+})
+.catch((err) => {
+ console.log(err);
+})
\ No newline at end of file
diff --git a/examples/audio.js b/examples/audio.js
new file mode 100644
index 0000000..bb1ee80
--- /dev/null
+++ b/examples/audio.js
@@ -0,0 +1,17 @@
+const TwoCaptcha = require("../dist/index.js");
+require('dotenv').config();
+const APIKEY = process.env.APIKEY
+const solver = new TwoCaptcha.Solver(APIKEY);
+const fs = require('fs')
+const audioCaptchaBase64 = fs.readFileSync("./media/example.mp3", "base64")
+
+solver.audio({
+ body: audioCaptchaBase64,
+ lang: 'en'
+})
+.then((res) => {
+ console.log(res);
+})
+.catch((err) => {
+ console.log(err);
+})
\ No newline at end of file
diff --git a/examples/canvas.js b/examples/canvas.js
new file mode 100644
index 0000000..e4cb1cc
--- /dev/null
+++ b/examples/canvas.js
@@ -0,0 +1,19 @@
+const TwoCaptcha = require("../dist/index.js");
+require('dotenv').config();
+const APIKEY = process.env.APIKEY
+const solver = new TwoCaptcha.Solver(APIKEY);
+const fs = require('fs')
+const imageBase64 = fs.readFileSync("./media/canvas.png", "base64")
+const imginstructionsBase64 = fs.readFileSync("./media/canvasImgInstructions.jpg", "base64")
+
+solver.canvas({
+ body: imageBase64,
+ textinstructions: 'Highlight the red CIRCLE',
+ imginstructions: imginstructionsBase64,
+})
+.then((res) => {
+ console.log(res);
+})
+.catch((err) => {
+ console.log(err);
+})
\ No newline at end of file
diff --git a/examples/cutcaptcha.js b/examples/cutcaptcha.js
new file mode 100644
index 0000000..c7aae38
--- /dev/null
+++ b/examples/cutcaptcha.js
@@ -0,0 +1,16 @@
+const TwoCaptcha = require("../dist/index.js");
+require('dotenv').config();
+const APIKEY = process.env.APIKEY
+const solver = new TwoCaptcha.Solver(APIKEY);
+
+solver.cutCaptcha({
+ pageurl: "https://mysite.com/page/with/cutcaptcha",
+ miseryKey: "098e6a849af406142e3150dbf4e6d0538db2b51f",
+ apiKey: "SAs61IAI",
+})
+.then((res) => {
+console.log(res);
+})
+.catch((err) => {
+console.log(err);
+})
\ No newline at end of file
diff --git a/examples/grid.js b/examples/grid.js
index 0b9c9b3..0f26842 100644
--- a/examples/grid.js
+++ b/examples/grid.js
@@ -3,11 +3,15 @@ require('dotenv').config();
const APIKEY = process.env.APIKEY
const solver = new TwoCaptcha.Solver(APIKEY);
const fs = require('fs')
-const imageBase64 = fs.readFileSync("./media/recaptchaGrid3x3.jpg", "base64")
+const imageBase64 = fs.readFileSync("./media/recaptchaGrid4x4.jpg", "base64")
+const instructionsImageBase64 = fs.readFileSync("./media/recaptchaGridImginstructions4x4.jpg", "base64")
solver.grid({
body: imageBase64,
- textinstructions: "Select cars in the image"
+ textinstructions: "Select all squares with stairs",
+ imginstructions: instructionsImageBase64,
+ cols: 4,
+ rows: 4
})
.then((res) => {
console.log(res);
diff --git a/examples/grid_options.js b/examples/grid_options.js
index 694bbed..0d1bdd8 100644
--- a/examples/grid_options.js
+++ b/examples/grid_options.js
@@ -8,7 +8,7 @@ const imageInstructionsBase64 = fs.readFileSync("./media/recaptchaGridImginstruc
solver.grid({
body: imageBase64,
- textinstructions: "Select all squares with stairs",
+ textinstructions: "select all squares with stairs if there are none, click skip",
imginstructions: imageInstructionsBase64,
cols: 4,
rows: 4,
@@ -16,6 +16,7 @@ solver.grid({
maxClicks: 6,
lang: "en",
canSkip: 1,
+ imgType: "recaptcha" /* More information about the `img_type` parameter can be found at: https://2captcha.com/2captcha-api#grid */
// pingback: '123.123.123.123' /* More info about pingback https://2captcha.com/setting/pingback */
// previousId: '123456789'
})
@@ -24,4 +25,4 @@ solver.grid({
})
.catch((err) => {
console.log(err);
- });
+ });
\ No newline at end of file
diff --git a/examples/keyCaptcha.js b/examples/keyCaptcha.js
new file mode 100644
index 0000000..f91535d
--- /dev/null
+++ b/examples/keyCaptcha.js
@@ -0,0 +1,18 @@
+const TwoCaptcha = require("../dist/index.js");
+require('dotenv').config();
+const APIKEY = process.env.APIKEY
+const solver = new TwoCaptcha.Solver(APIKEY);
+
+solver.keyCaptcha({
+ pageurl: "https://2captcha.com/demo/keycaptcha",
+ userId: '184015',
+ sessionId: '0917788cad24ad3a69813c4fcd556061',
+ webServerSign: '02f7f9669f1269595c4c69bcd4a3c52e',
+ webServerSign2: 'd888700f6f324ec0f32b44c32c50bde1'
+})
+.then((res) => {
+ console.log(res);
+})
+.catch((err) => {
+ console.log(err);
+})
\ No newline at end of file
diff --git a/examples/media/canvas.png b/examples/media/canvas.png
new file mode 100644
index 0000000..f0dc728
Binary files /dev/null and b/examples/media/canvas.png differ
diff --git a/examples/media/canvasImgInstructions.jpg b/examples/media/canvasImgInstructions.jpg
new file mode 100644
index 0000000..bbda874
Binary files /dev/null and b/examples/media/canvasImgInstructions.jpg differ
diff --git a/examples/media/example.mp3 b/examples/media/example.mp3
new file mode 100644
index 0000000..c063a6a
Binary files /dev/null and b/examples/media/example.mp3 differ
diff --git a/examples/media/rotatecaptcha.png b/examples/media/rotatecaptcha.png
new file mode 100644
index 0000000..4602d7d
Binary files /dev/null and b/examples/media/rotatecaptcha.png differ
diff --git a/examples/recaptcha.js b/examples/recaptcha_v2.js
similarity index 100%
rename from examples/recaptcha.js
rename to examples/recaptcha_v2.js
diff --git a/examples/rotate.js b/examples/rotate.js
new file mode 100644
index 0000000..e7a50be
--- /dev/null
+++ b/examples/rotate.js
@@ -0,0 +1,18 @@
+const TwoCaptcha = require("../dist/index.js");
+require('dotenv').config();
+const APIKEY = process.env.APIKEY
+const solver = new TwoCaptcha.Solver(APIKEY);
+const fs = require('fs')
+const imageBase64 = fs.readFileSync("./media/rotatecaptcha.png", "base64")
+
+solver.rotate({
+ body: imageBase64,
+ angle: 15,
+ textinstructions: "Rotate the object to the correct position"
+})
+.then((res) => {
+ console.log(res);
+})
+.catch((err) => {
+ console.log(err);
+})
\ No newline at end of file
diff --git a/examples/tencent.js b/examples/tencent.js
new file mode 100644
index 0000000..d077de4
--- /dev/null
+++ b/examples/tencent.js
@@ -0,0 +1,15 @@
+const TwoCaptcha = require("../dist/index.js");
+require('dotenv').config();
+const APIKEY = process.env.APIKEY
+const solver = new TwoCaptcha.Solver(APIKEY);
+
+solver.tencent({
+ pageurl: "https://mysite.com/page/with/tencent",
+ appId: "189956587"
+})
+.then((res) => {
+ console.log(res);
+})
+.catch((err) => {
+ console.log(err);
+})
\ No newline at end of file
diff --git a/examples/text.js b/examples/text.js
new file mode 100644
index 0000000..ceaf3c1
--- /dev/null
+++ b/examples/text.js
@@ -0,0 +1,15 @@
+const TwoCaptcha = require("../dist/index.js");
+require('dotenv').config();
+const APIKEY = process.env.APIKEY
+const solver = new TwoCaptcha.Solver(APIKEY);
+
+solver.text({
+ textcaptcha: "If tomorrow is Saturday, what day is today?",
+ lang: 'en'
+})
+.then((res) => {
+ console.log(res);
+ })
+.catch((err) => {
+ console.log(err);
+})
\ No newline at end of file
diff --git a/src/structs/2captcha.ts b/src/structs/2captcha.ts
index d089469..7802974 100644
--- a/src/structs/2captcha.ts
+++ b/src/structs/2captcha.ts
@@ -43,7 +43,6 @@ export interface paramsHCaptcha {
domain?: string
}
-// FixMe:data[key] - how to send this parameter
export interface paramsFunCaptcha {
publickey: string,
pageurl: string,
@@ -84,18 +83,6 @@ export interface paramsGeetest {
userAgent?: string
}
-/**
- * Interface for yandexSmart captcha
- *
- * @typedef {object} yandexSmart
- * @property {string} pageurl URL of the page where the captcha is located
- * @property {string} sitekey The `sitekey` value you found on the captcha page
- * @property {string} pingback
- * @property {string} proxy Format: `login:password@123.123.123.123:3128`. You can find more info about proxies [here](https://2captcha.com/2captcha-api#proxies).
- * @property {string} proxytype Type of your proxy: `HTTP`, `HTTPS`, `SOCKS4`, `SOCKS5`.
- * @property {string} userAgent Your `userAgent` that will be passed to our worker and used to solve the captcha.
- *
- */
export interface yandexSmart {
pageurl: string,
sitekey: string,
@@ -105,18 +92,6 @@ export interface yandexSmart {
userAgent?: string
}
-/**
- * Interface for GeeTest V4 captcha
- *
- * @typedef {object} paramsGeeTestV4
- * @property {string} pageurl Required parameter. URL of the page where the captcha is located
- * @property {string} captcha_id Required parameter. Value of `captcha_id` parameter you found on target website.
- * @property {string} pingback An optional param. [More info here](https://2captcha.com/2captcha-api#pingback).
- * @property {string} proxy An optional param. Format: `login:password@123.123.123.123:3128`
- * @property {string} proxytype An optional param. Type of your proxy: `HTTP`, `HTTPS`, `SOCKS4`, `SOCKS5`.
- * @property {string} userAgent An optional param. Your `userAgent` that will be passed to our worker and used to solve the captcha.
- *
- */
export interface paramsGeeTestV4 {
pageurl: string,
captcha_id: string,
@@ -208,6 +183,15 @@ export interface paramsMTCaptcha {
proxytype?: string,
}
+export interface paramsCutcaptcha {
+ pageurl: string,
+ miseryKey: string,
+ apiKey: string,
+ pingback?: string,
+ proxy?: string,
+ proxytype?: string
+}
+
export interface friendlyCaptcha {
pageurl: string,
sitekey: string,
@@ -224,12 +208,14 @@ export interface paramsBoundingBox {
export interface paramsGrid {
body: string,
- recaptcha: 1,
+ recaptcha: number,
+ canvas?: number,
rows?: number,
cols?: number,
- min小licks?: number,
- max小licks?: number,
+ minClicks?: number,
+ maxClicks?: number,
previousId?: string,
+ imgType?: string,
textinstructions?: string,
imginstructions?: string,
canSkip?: number,
@@ -237,6 +223,55 @@ export interface paramsGrid {
pingback?: string,
}
+export interface paramsTextcaptcha {
+ textcaptcha: string,
+ lang?: string,
+ pingback?: string,
+}
+
+export interface paramsRotateCaptcha {
+ body: string,
+ angle?: number,
+ pingback?: string,
+ lang?: string,
+ textinstructions?: string,
+ imginstructions?: string
+}
+
+export interface paramsKeyCaptcha {
+ pageurl: string,
+ userId: string,
+ sessionId: string,
+ webServerSign: string,
+ webServerSign2: string,
+ pingback?: string,
+ proxy?: string,
+ proxytype?: string
+}
+
+export interface paramsTencent {
+ pageurl: string,
+ appId: string,
+ pingback?: string,
+ proxy?: string,
+ proxytype?: string
+}
+
+export interface paramsAtbCaptcha{
+ pageurl: string,
+ appId: string,
+ apiServer: string,
+ pingback?: string,
+ proxy?: string,
+ proxytype?: string
+}
+
+export interface paramsAudioCaptcha {
+ body: string,
+ lang: string,
+ pingback?: string,
+}
+
/**
* An object containing properties of the captcha solution.
* @typedef {Object} CaptchaAnswer
@@ -900,7 +935,7 @@ export class Solver {
*
* [Read more about Cloudflare Turnstile captcha](https://2captcha.com/2captcha-api#turnstile).
*
- * @param {{ pageurl, sitekey, action, data, pingback, proxy, proxytype}} params The `褋loudflareTurnstile` method takes arguments as an object. Thus, the `pageurl`, `sitekey` fields in the passed object are mandatory.
+ * @param {{ pageurl, sitekey, action, data, pingback, proxy, proxytype}} params The `cloudflareTurnstile` method takes arguments as an object. Thus, the `pageurl`, `sitekey` fields in the passed object are mandatory.
* @param {string} params.pageurl Full `URL` of the page where you see the captcha.
* @param {string} params.sitekey Is a value of `sitekey` parameter in the page source.
* @param {string} params.action Value of optional `action` parameter you found on page.
@@ -949,7 +984,7 @@ export class Solver {
/**
* ### Solves a Coordinates captcha.
*
- * @param {{ body, imginstructions, textinstructions, language, lang, pingback }} params parameters 小oordinates Captcha as an object.
+ * @param {{ body, imginstructions, textinstructions, language, lang, pingback }} params parameters Coordinates Captcha as an object.
* @param {string} params.body Base64-encoded captcha image.
* @param {string} params.imginstructions Base64-encoded image with instruction for solving captcha.
* @param {string} params.textinstructions Text will be shown to worker to help him to solve the captcha correctly. For example: click on all objects in red color.
@@ -1206,37 +1241,51 @@ public async mtCaptcha(params: paramsMTCaptcha): Promise {
}
/**
- * ### Solves Cutcaptcha
+ * ### Solves a Cutcaptcha.
*
- * @param {{ pageurl, sitekey, userAgent, pingback, proxy, proxytype}} params Parameters MTCaptcha as an object.
- * @param {string} params.pageurl Full `URL` of the page where you see the captcha.
- * @param {string} params.sitekey TThe value of `sitekey` parameter found on the page.
- * @param {string} params.pingback URL for pingback (callback) response that will be sent when captcha is solved. URL should be registered on the server. [More info here](https://2captcha.com/2captcha-api#pingback).
- * @param {string} params.proxy Format: `login:password@123.123.123.123:3128` You can find more info about proxies [here](https://2captcha.com/2captcha-api#proxies).
- * @param {string} params.proxytype Type of your proxy: `HTTP`, `HTTPS`, `SOCKS4`, `SOCKS5`.
+ * Use this method to solve Cutcaptcha. Returns the response in JSON.
+ * [Read more about Cutcaptcha Method](https://2captcha.com/2captcha-api#cutcaptcha).
*
- * @example
+ * @param {{ pageurl, miseryKey, apiKey, pingback, proxy, proxytype }} params Parameters for solving Cutcaptcha as an object.
+ * @param {string} params.pageurl The URL where the captcha is located.
+ * @param {string} params.miseryKey The value of `CUTCAPTCHA_MISERY_KEY` variable defined on page.
+ * @param {string} params.apiKey The value of `data-apikey` attribute of iframe's body. Also the name of javascript file included on the page
+ * @param {string} [params.pingback] Optional param. URL for pingback (callback) response when captcha is solved.
+ * @param {string} [params.proxy] Optional param. Proxy to use while solving the captcha. Format: `login:password@123.123.123.123:3128`.
+ * @param {string} [params.proxytype] Optional param. Type of your proxy: `HTTP`, `HTTPS`, `SOCKS4`, `SOCKS5`.
+ *
+ * @returns {Promise} The result from the solve.
+ * @throws APIError
+ *
+ * @example
* solver.cutCaptcha({
- * pageurl: "https://service.mtcaptcha.com/mtcv1/demo/index.html",
- * sitekey: "MTPublic-DemoKey9M"
+ * pageurl: "https://mysite.com/page/with/cutcaptcha",
+ * miseryKey: "098e6a849af406142e3150dbf4e6d0538db2b51f",
+ * apiKey: "SAs61IAI",
* })
* .then((res) => {
- * console.log(res);
- * })
+ * console.log(res);
+ * })
* .catch((err) => {
- * console.log(err);
+ * console.log(err);
* })
*/
-public async cutCaptcha(params: paramsMTCaptcha): Promise {
- checkCaptchaParams(params, "mt_captcha")
+public async cutCaptcha(params: paramsCutcaptcha): Promise {
+ params = renameParams(params)
+ checkCaptchaParams(params, "cutcaptcha")
const payload = {
...params,
- method: "mt_captcha",
+ method: "cutcaptcha",
...this.defaultPayload,
}
- const response = await fetch(this.in + utils.objectToURI(payload))
+ const URL = this.in
+ const response = await fetch(URL, {
+ body: JSON.stringify(payload),
+ method: "post",
+ headers: {'Content-Type': 'application/json'}
+ })
const result = await response.text()
let data;
@@ -1358,14 +1407,15 @@ public async boundingBox(params: paramsBoundingBox): Promise {
*
* The method can be used to bypass tasks where a grid is applied to an image and you need to click on grid tiles, like reCAPTCHA or hCaptcha images.
*
- * @param {{ body, textinstructions, imginstructions, rows, cols, min小licks, max小licks, previousId, canSkip, lang, pingback}} params Parameters Grid Method as an object.
+ * @param {{ body, textinstructions, imginstructions, rows, cols, minClicks, maxClicks, imgType, previousId, canSkip, lang, pingback}} params Parameters Grid Method as an object.
* @param {string} params.body `Base64`- encoded captcha image.
* @param {string} params.textinstructions Text will be shown to worker to help him to select object on the image correctly. For example: "*Select cars in the image*". **Optional parameter**, if the instruction already exists in the form of the `imginstructions`.
* @param {string} params.imginstructions Image with instruction for worker to help him to select object on the image correctly. The image must be encoded in `Base64` format. **Optional parameter**, if the instruction already exists in the form of the `textinstructions`.
* @param {number} params.rows Number of rows in grid captcha.
* @param {number} params.cols Number of columns in grid captcdha.
- * @param {number} params.min小licks The minimum number of tiles that must be selected. Can't be more than `rows` * `cols`.
- * @param {number} params.max小licks The maximum number of tiles that can be selected on the image.
+ * @param {number} params.minClicks The minimum number of tiles that must be selected. Can't be more than `rows` * `cols`.
+ * @param {number} params.maxClicks The maximum number of tiles that can be selected on the image.
+ * @param {string} params.imgType The image will be recognized using Computer Vision. Supported value options: `recaptcha`, `hcaptcha`, `funcaptcha`, `funcaptcha_compare`. [More info here](https://2captcha.com/2captcha-api#grid).
* @param {string} params.previousId Id of your previous request with the same captcha challenge.
* @param {number} params.canSkip Set the value to `1` only if it's possible that there's no images matching to the instruction. We'll provide a button "No matching images" to worker and you will receive `No_matching_images` as answer.
* @param {string} params.lang Language code. [See the list of supported languages](https://2captcha.com/2captcha-api#language).
@@ -1418,6 +1468,430 @@ public async grid(params: paramsGrid): Promise {
}
}
+/**
+ * ### Text Captcha method
+ *
+ * Text Captcha is a type of captcha that is represented as text and doesn't contain images. Usually you have to answer a question to pass the verification. For example: "If tomorrow is Saturday, what day is today?".
+ * [Read more about Text Captcha Method](https://2captcha.com/2captcha-api#text-captcha).
+ *
+ * @param {{ textcaptcha, lang, pingback}} params Parameters Text Captcha Method as an object.
+ * @param {string} params.textcaptcha Text Captcha is a type of captcha that is represented as text and doesn't contain images. Usually you have to answer a question to pass the verification.
+ * @param {string} params.lang Language code. [See the list of supported languages](https://2captcha.com/2captcha-api#language).
+ * @param {string} params.pingback params.pingback URL for pingback (callback) response that will be sent when captcha is solved. URL should be registered on the server. [More info here](https://2captcha.com/2captcha-api#pingback).
+ *
+ * @example
+ * solver.text({
+ * textcaptcha: "If tomorrow is Saturday, what day is today?",
+ * lang: 'en'
+ * })
+ * .then((res) => {
+ * console.log(res);
+ * })
+ * .catch((err) => {
+ * console.log(err);
+ * })
+ */
+public async text(params: paramsTextcaptcha): Promise {
+ checkCaptchaParams(params, "textcaptcha")
+
+ params = await renameParams(params)
+
+ const payload = {
+ ...params,
+ ...this.defaultPayload,
+ }
+
+ const URL = this.in
+ const response = await fetch(URL, {
+ body: JSON.stringify( payload ),
+ method: "post",
+ headers: {'Content-Type': 'application/json'}
+ })
+ const result = await response.text()
+
+ let data;
+ try {
+ data = JSON.parse(result)
+ } catch {
+ throw new APIError(result)
+ }
+
+ if (data.status == 1) {
+ return this.pollResponse(data.request)
+ } else {
+ throw new APIError(data.request)
+ }
+}
+
+/**
+ * ### Canvas method
+ *
+ * This method can be used to bypass tasks in which you need to circle an object or line in an image.
+ * [Read more about Canvas Method](https://2captcha.com/2captcha-api#canvas).
+ *
+ * @param {{ body, textinstructions, imginstructions, canSkip, lang, pingback}} params Parameters Canvas as an object.
+ * @param {string} params.body `Base64`- encoded captcha image.
+ * @param {string} params.textinstructions Text will be shown to worker to help him to select object on the image correctly. For example: "*Select cars in the image*". **Optional parameter**, if the instruction already exists in the form of the `imginstructions`.
+ * @param {string} params.imginstructions Image with instruction for worker to help him to select object on the image correctly. The image must be encoded in `Base64` format. **Optional parameter**, if the instruction already exists in the form of the `textinstructions`.
+ * @param {number} params.canSkip Set the value to `1` only if it's possible that there's no images matching to the instruction. We'll provide a button "No matching images" to worker and you will receive `No_matching_images` as answer.
+ * @param {string} params.lang Language code. [See the list of supported languages](https://2captcha.com/2captcha-api#language).
+ * @param {string} params.pingback params.pingback URL for pingback (callback) response that will be sent when captcha is solved. URL should be registered on the server. [More info here](https://2captcha.com/2captcha-api#pingback).
+ *
+ * @example
+ * solver.canvas({
+ * body: 'iVBORw0KGgoAAAANSgAAAcIA...',
+ * imginstructions: '/9j/4AAQSkZJRgABAQEA...',
+ * textinstructions: 'Highlight the red CIRCLE'
+ * })
+ * .then((res) => {
+ * console.log(res);
+ * })
+ * .catch((err) => {
+ * console.log(err);
+ * })
+ */
+public async canvas(params: paramsGrid): Promise {
+ checkCaptchaParams(params, "canvas")
+
+ params = await renameParams(params)
+
+ const payload = {
+ ...params,
+ recaptcha: 1,
+ canvas: 1,
+ method: "base64",
+ ...this.defaultPayload,
+ }
+
+ const URL = this.in
+ const response = await fetch(URL, {
+ body: JSON.stringify( payload ),
+ method: "post",
+ headers: {'Content-Type': 'application/json'}
+ })
+ const result = await response.text()
+
+ let data;
+ try {
+ data = JSON.parse(result)
+ } catch {
+ throw new APIError(result)
+ }
+
+ if (data.status == 1) {
+ return this.pollResponse(data.request)
+ } else {
+ throw new APIError(data.request)
+ }
+}
+
+/**
+ * ### Rotate method
+ *
+ * This method can be used to solve a captcha that asks to rotate an object. It is mostly used to bypass FunCaptcha. Returns the rotation angle.
+ * [Read more about Rotate Method](https://2captcha.com/2captcha-api#solving_rotatecaptcha).
+ *
+ * @param {{ body, angle, pingback, lang, textinstructions, imginstructions }} params Parameters for solving Rotate Captcha as an object.
+ * @param {string} params.body Base64-encoded image of the captcha that needs to be rotated.
+ * @param {number} params.angle Angle to which the captcha needs to be rotated to solve it correctly. Value between `0` to `360`.
+ * @param {string} params.textinstructions Optional param. Text instruction that will be shown to worker to help solve the captcha correctly.
+ * @param {string} params.imginstructions Optional param. Base64-encoded image instruction that will be shown to worker to help solve the captcha correctly.
+ * @param {string} params.lang Optional param. Language code for worker to use while solving the captcha.
+ * @param {string} params.pingback Optional param. URL for pingback (callback) response when captcha is solved.
+ *
+ * @returns {Promise} The result from the solve.
+ * @throws APIError
+ *
+ * @example
+ * solver.rotate({
+ * body: "iVBORw0KGgoAAAANSUhEUgAAAcIA...",
+ * angle: 15,
+ * textinstructions: "Rotate the object to the correct position"
+ * })
+ * .then((res) => {
+ * console.log(res);
+ * })
+ * .catch((err) => {
+ * console.log(err);
+ * })
+ */
+public async rotate(params: paramsRotateCaptcha): Promise {
+ checkCaptchaParams(params, "rotatecaptcha")
+
+ const payload = {
+ ...params,
+ method: "rotatecaptcha",
+ ...this.defaultPayload,
+ }
+
+ const URL = this.in
+ const response = await fetch(URL, {
+ body: JSON.stringify(payload),
+ method: "post",
+ headers: {'Content-Type': 'application/json'}
+ })
+ const result = await response.text()
+
+ let data;
+ try {
+ data = JSON.parse(result)
+ } catch {
+ throw new APIError(result)
+ }
+
+ if (data.status == 1) {
+ return this.pollResponse(data.request)
+ } else {
+ throw new APIError(data.request)
+ }
+}
+
+
+/**
+* ### Solves a KeyCaptcha.
+*
+* This method can be used to solve a KeyCaptcha. It is mostly used to bypass captchas that use KeyCaptcha technology.
+* [Read more about KeyCaptcha Method](https://2captcha.com/2captcha-api#solving_keycaptcha).
+*
+* @param {{ pageurl, userId, sessionId, webServerSign, webServerSign2, pingback, proxy, proxytype }} params Parameters for solving KeyCaptcha as an object.
+* @param {string} params.pageurl The URL where the captcha is located.
+* @param {string} params.userId Value of `s_s_c_user_id` parameter you found on page.
+* @param {string} params.sessionId Value of `s_s_c_session_id` parameter you found on page.
+* @param {string} params.webServerSign Value of `s_s_c_web_server_sign` parameter you found on page.
+* @param {string} params.webServerSign2 Value of `s_s_c_web_server_sign2` parameter you found on page.
+* @param {string} [params.pingback] Optional param. URL for pingback (callback) response when captcha is solved.
+* @param {string} [params.proxy] Optional param. Proxy to use while solving the captcha. Format: `login:password@123.123.123.123:3128`.
+* @param {string} [params.proxytype] Optional param. Type of your proxy: `HTTP`, `HTTPS`, `SOCKS4`, `SOCKS5`.
+*
+* @returns {Promise} The result from the solve.
+* @throws APIError
+*
+* @example
+* solver.keyCaptcha({
+* pageurl: "https://2captcha.com/demo/keycaptcha",
+* userId: "184015",
+* sessionId: "11975dc265ce9174a54edb1619af15b7",
+* webServerSign: "73ef77fd3cf0ce02947d9088bdc8412a",
+* webServerSign2: "93836d9e7007f38f072ce07d89bb7e2b"
+* })
+* .then((res) => {
+* console.log(res);
+* })
+* .catch((err) => {
+* console.log(err);
+* })
+*/
+public async keyCaptcha(params: paramsKeyCaptcha): Promise {
+ params = await renameParams(params)
+ checkCaptchaParams(params, "keycaptcha")
+
+ const payload = {
+ ...params,
+ method: "keycaptcha",
+ ...this.defaultPayload,
+ }
+
+ const URL = this.in
+ const response = await fetch(URL, {
+ body: JSON.stringify(payload),
+ method: "post",
+ headers: {'Content-Type': 'application/json'}
+ })
+ const result = await response.text()
+
+ let data;
+ try {
+ data = JSON.parse(result)
+ } catch {
+ throw new APIError(result)
+ }
+
+ if (data.status == 1) {
+ return this.pollResponse(data.request)
+ } else {
+ throw new APIError(data.request)
+ }
+}
+
+/**
+* ### Solves a Tencent.
+*
+* Use this method to solve Tencent captcha. Returns a token.
+* [Read more about Tencent Method](https://2captcha.com/2captcha-api#tencent).
+*
+* @param {{ pageurl, appId, pingback, proxy, proxytype }} params Parameters for solving Tencent as an object.
+* @param {string} params.pageurl The URL where the captcha is located.
+* @param {string} params.appId The value of `appId` parameter in the website source code.
+* @param {string} [params.pingback] Optional param. URL for pingback (callback) response when captcha is solved.
+* @param {string} [params.proxy] Optional param. Proxy to use while solving the captcha. Format: `login:password@123.123.123.123:3128`.
+* @param {string} [params.proxytype] Optional param. Type of your proxy: `HTTP`, `HTTPS`, `SOCKS4`, `SOCKS5`.
+*
+* @returns {Promise} The result from the solve.
+* @throws APIError
+*
+* @example
+* solver.tencent({
+* pageurl: "https://mysite.com/page/with/tencent",
+* appId: "189956587"
+* })
+* .then((res) => {
+* console.log(res);
+* })
+* .catch((err) => {
+* console.log(err);
+* })
+*/
+public async tencent(params: paramsTencent): Promise {
+ params = await renameParams(params)
+ checkCaptchaParams(params, "tencent")
+
+ const payload = {
+ ...params,
+ method: "tencent",
+ ...this.defaultPayload,
+ }
+
+ const URL = this.in
+ const response = await fetch(URL, {
+ body: JSON.stringify(payload),
+ method: "post",
+ headers: {'Content-Type': 'application/json'}
+ })
+ const result = await response.text()
+
+ let data;
+ try {
+ data = JSON.parse(result)
+ } catch {
+ throw new APIError(result)
+ }
+
+ if (data.status == 1) {
+ return this.pollResponse(data.request)
+ } else {
+ throw new APIError(data.request)
+ }
+}
+
+/**
+* ### Solves a atbCAPTCHA.
+*
+* Use this method to solve atbCAPTCHA captcha. Returns a token.
+* [Read more about atbCAPTCHA Method](https://2captcha.com/2captcha-api#atb-captcha).
+*
+* @param {{ pageurl, appId, apiServer, pingback, proxy, proxytype }} params Parameters for solving atbCAPTCHA as an object.
+* @param {string} params.pageurl The URL where the captcha is located.
+* @param {string} params.appId The value of `appId` parameter in the website source code.
+* @param {string} params.apiServer The value of `apiServer` parameter in the website source code.
+* @param {string} [params.pingback] Optional param. URL for pingback (callback) response when captcha is solved.
+* @param {string} [params.proxy] Optional param. Proxy to use while solving the captcha. Format: `login:password@123.123.123.123:3128`.
+* @param {string} [params.proxytype] Optional param. Type of your proxy: `HTTP`, `HTTPS`, `SOCKS4`, `SOCKS5`.
+*
+* @returns {Promise} The result from the solve.
+* @throws APIError
+*
+* @example
+* solver.atbCaptcha({
+* pageurl: "https://mysite.com/page/with/tencent",
+* appId: "af25e409b33d722a95e56a230ff8771c",
+ apiServer: "https://cap.aisecurius.com"
+* })
+* .then((res) => {
+* console.log(res);
+* })
+* .catch((err) => {
+* console.log(err);
+* })
+*/
+public async atbCaptcha(params: paramsAtbCaptcha): Promise {
+ params = await renameParams(params)
+ checkCaptchaParams(params, "atb_captcha")
+
+ const payload = {
+ ...params,
+ method: "atb_captcha",
+ ...this.defaultPayload,
+ }
+
+ const URL = this.in
+ const response = await fetch(URL, {
+ body: JSON.stringify(payload),
+ method: "post",
+ headers: {'Content-Type': 'application/json'}
+ })
+ const result = await response.text()
+
+ let data;
+ try {
+ data = JSON.parse(result)
+ } catch {
+ throw new APIError(result)
+ }
+
+ if (data.status == 1) {
+ return this.pollResponse(data.request)
+ } else {
+ throw new APIError(data.request)
+ }
+}
+
+
+/**
+ * ### Method for solving Audio captcha.
+ *
+ * Use the following method to bypass an audio captcha (`mp3` formats only). You must provide the language as `lang = 'en'`. Supported languages are "en", "ru", "de", "el", "pt", "fr".
+ * [Read more about Audio recognition Method](https://2captcha.com/2captcha-api#audio-recognition).
+ *
+ * @param {{ body, lang, pingback }} params Object containing parameters for the audio captcha.
+ * @param {string} params.body Base64 encoded audio file in `mp3` format. Max file size: 1 MB.
+ * @param {string} params.lang The language of audio record. Supported languages are: "en", "ru", "de", "el", "pt", "fr".
+ * @param {string} [params.pingback] URL for pingback response once captcha is solved.
+ *
+ * @returns {Promise} The result from solving the audio captcha.
+ * @throws APIError
+ * @example
+ * solver.audio({
+ * body: "SUQzBAAAAAAAHFRTU0UAAAA...",
+ * lang: "en"
+ * })
+ * .then((res) => {
+ * console.log(res);
+ * })
+ * .catch((err) => {
+ * console.log(err);
+ * })
+ */
+public async audio(params: paramsAudioCaptcha): Promise {
+ checkCaptchaParams(params, "audio")
+
+ const payload = {
+ ...params,
+ method: "audio",
+ ...this.defaultPayload
+ }
+
+ const response = await fetch(this.in, {
+ method: 'post',
+ body: JSON.stringify(payload),
+ headers: {'Content-Type': 'application/json'}
+ })
+
+ const result = await response.text()
+
+ let data;
+ try {
+ data = JSON.parse(result)
+ } catch {
+ throw new APIError(result)
+ }
+
+ if (data.status == 1) {
+ return this.pollResponse(data.request)
+ } else {
+ throw new APIError(data.request)
+ }
+}
+
/**
* Reports a captcha as correctly solved.
*
diff --git a/src/utils/checkCaptchaParams.ts b/src/utils/checkCaptchaParams.ts
index dbc00d0..9e63fd7 100644
--- a/src/utils/checkCaptchaParams.ts
+++ b/src/utils/checkCaptchaParams.ts
@@ -1,6 +1,7 @@
// Captcha methods for which parameter checking is available
const supportedMethods = ["userrecaptcha", "hcaptcha", "geetest", "geetest_v4","yandex","funcaptcha","lemin","amazon_waf",
-"turnstile", "base64", "capy","datadome", "cybersiara", "mt_captcha", "bounding_box", 'friendly_captcha', 'grid']
+"turnstile", "base64", "capy","datadome", "cybersiara", "mt_captcha", "bounding_box", 'friendly_captcha', 'grid',
+ 'textcaptcha', 'canvas', 'rotatecaptcha', 'keycaptcha', 'cutcaptcha', 'tencent', 'atb_captcha', 'audio']
// Names of required fields that must be contained in the parameters captcha
const recaptchaRequiredFields = ['pageurl','googlekey']
@@ -16,11 +17,19 @@ const turnstileRequiredFields = ['pageurl','sitekey']
const base64RequiredFields = ['body']
const capyPuzzleRequiredFields = ['captchakey']
const dataDomeRequiredFields = ['pageurl', 'captcha_url', 'userAgent', 'proxy', 'proxytype']
-const 褋yberSiARARequiredFields = ['pageurl', 'master_url_id', 'userAgent']
-const mt小aptchaRequiredFields = ['pageurl', 'sitekey']
+const cyberSiARARequiredFields = ['pageurl', 'master_url_id', 'userAgent']
+const mtCaptchaRequiredFields = ['pageurl', 'sitekey']
const boundingBoxRequiredFields = ['image'] // and textinstructions or imginstructions
const friendlyCaptchaFields = ['pageurl','sitekey']
const gridRequiredFields = ['body'] // and textinstructions or imginstructions
+const textCaptchaRequiredFields = ['textcaptcha']
+const canvasRequiredFields = ['body'] // and textinstructions or imginstructions
+const rotateRequiredFields = ['body']
+const keycaptchaRequiredFields = ['pageurl', 's_s_c_user_id', 's_s_c_session_id', 's_s_c_web_server_sign', 's_s_c_web_server_sign2']
+const cutcaptchaRequiredFields = ['pageurl', 'misery_key', 'api_key']
+const tencentRequiredFields = ['pageurl', 'app_id']
+const atbCaptchaRequiredFields = ['pageurl', 'app_id', 'api_server']
+const audioRequiredFields = ['body', 'lang']
/**
* Getting required arguments for a captcha.
@@ -72,10 +81,10 @@ const getRequiredFildsArr = (method: string):Array => {
requiredFieldsArr = dataDomeRequiredFields
break;
case "cybersiara":
- requiredFieldsArr = 褋yberSiARARequiredFields
+ requiredFieldsArr = cyberSiARARequiredFields
break;
case "mt_captcha":
- requiredFieldsArr = mt小aptchaRequiredFields
+ requiredFieldsArr = mtCaptchaRequiredFields
break;
case "bounding_box":
requiredFieldsArr = boundingBoxRequiredFields
@@ -83,11 +92,43 @@ const getRequiredFildsArr = (method: string):Array => {
case "friendly_captcha":
requiredFieldsArr = friendlyCaptchaFields
break;
+ case "textcaptcha":
+ requiredFieldsArr = textCaptchaRequiredFields
+ break;
+ case "canvas":
+ requiredFieldsArr = canvasRequiredFields
+ break;
+ case "rotatecaptcha":
+ requiredFieldsArr = rotateRequiredFields
+ break;
+ case "keycaptcha":
+ requiredFieldsArr = keycaptchaRequiredFields
+ break;
+ case "cutcaptcha":
+ requiredFieldsArr = cutcaptchaRequiredFields
+ break;
+ case "tencent":
+ requiredFieldsArr = tencentRequiredFields
+ break;
+ case "atb_captcha":
+ requiredFieldsArr = atbCaptchaRequiredFields
+ break;
+ case "audio":
+ requiredFieldsArr = audioRequiredFields
+ break;
}
return requiredFieldsArr
}
/**
+ * ### Captcha Required Parameters Check.
+ *
+ * Checking required captcha parameters before sending.
+ * This function checks for required fields in the provided captcha parameters.
+ * Throws an error if the specified method is not supported or if required fields are missing.
+ *
+ * Note: The `checkCaptchaParams()` function should be called after `renameParams()`, if function `renameParams()` is used.
+ *
* @param { Object } params Captcha parameters that need to be checked.
* @returns true | false | Error
* @example
@@ -115,21 +156,13 @@ export default function checkCaptchaParams(params: Object, method: string) {
}
})
- if(method === "bounding_box") {
- if(params.hasOwnProperty('textinstructions') || params.hasOwnProperty('imginstructions')) {
- isCorrectCaptchaParams = true
- } else {
- isCorrectCaptchaParams = false
- throw new Error(`Error when check params captcha.\nNot found "textinstructions" or "imginstructions" field in the Object. One of this field is required for "bounding_box" method. Please add field "textinstructions" or "imginstructions" in object and try again.\nPlease correct your code for the "bounding_box" method according to the code examples.`)
- }
- }
-
- if(method === "grid") {
+ //The parameters `textinstructions` and `imginstructions` are mandatory for the methods `bounding_box`, `grid`, and `canvas`.
+ if(method === "bounding_box" || method === "grid" || method === "canvas") {
if(params.hasOwnProperty('textinstructions') || params.hasOwnProperty('imginstructions')) {
isCorrectCaptchaParams = true
} else {
isCorrectCaptchaParams = false
- throw new Error(`Error when check params captcha.\nNot found "textinstructions" or "imginstructions" field in the Object. One of this field is required for "Grid" method. Please add field "textinstructions" or "imginstructions" in object and try again.\nPlease correct your code for the "Grid" method according to the code examples.`)
+ throw new Error(`Error when check params captcha.\nNot found "textinstructions" or "imginstructions" field in the Object. One of this field is required for "${method}" method. Please add field "textinstructions" or "imginstructions" to captcha parameters.`)
}
}
diff --git a/src/utils/renameParams.ts b/src/utils/renameParams.ts
index 7945891..d3953e4 100644
--- a/src/utils/renameParams.ts
+++ b/src/utils/renameParams.ts
@@ -15,12 +15,30 @@ export default function renameParams(params: any) {
* Captcha parameters that need to be renamed before sent to the API.
*/
const replaceParams: any = {
+ // Grid
"cols" : "recaptchacols",
"rows" : "recaptcharows",
"minClicks" : "min_clicks",
"maxClicks" : "max_clicks",
"canSkip" : "can_no_answer",
- "previousId" : "previousID"
+ "previousId" : "previousID",
+ "imgType" : "img_type",
+
+ // KeyCaptcha
+ "userId" : "s_s_c_user_id",
+ "sessionId":"s_s_c_session_id",
+ "webServerSign":"s_s_c_web_server_sign",
+ "webServerSign2":"s_s_c_web_server_sign2",
+
+ // Cutcaptcha
+ "miseryKey":"misery_key",
+ "apiKey":"api_key",
+
+ // Tencent
+ "appId": "app_id",
+
+ // atbCAPTCHA
+ "apiServer": "api_server",
}
for(let key in params) {