@2captcha/captcha-solver 1.0.4 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +50 -4
- package/dist/structs/2captcha.d.ts +61 -21
- package/dist/structs/2captcha.d.ts.map +1 -1
- package/dist/structs/2captcha.js +76 -20
- package/dist/utils/checkCaptchaParams.d.ts.map +1 -1
- package/dist/utils/checkCaptchaParams.js +15 -2
- package/dist/utils/renameParams.d.ts +12 -0
- package/dist/utils/renameParams.d.ts.map +1 -0
- package/dist/utils/renameParams.js +36 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,8 +1,18 @@
|
|
|
1
|
-
|
|
1
|
+
<a href="https://github.com/2captcha/2captcha-python"><img src="https://github.com/user-attachments/assets/37e1d860-033b-4cf3-a158-468fc6b4debc" width="82" height="30"></a>
|
|
2
|
+
<a href="https://github.com/2captcha/2captcha-javascript"><img src="https://github.com/user-attachments/assets/371b271e-33c3-4217-af21-b95517a4677c" width="36" height="30"></a>
|
|
3
|
+
<a href="https://github.com/2captcha/2captcha-go"><img src="https://github.com/user-attachments/assets/ab22182e-6cb2-41fa-91f4-d5e89c6d7c6f" width="63" height="30"></a>
|
|
4
|
+
<a href="https://github.com/2captcha/2captcha-ruby"><img src="https://github.com/user-attachments/assets/0270d56f-79b0-4c95-9b09-4de89579914b" width="75" height="30"></a>
|
|
5
|
+
<a href="https://github.com/2captcha/2captcha-cpp"><img src="https://github.com/user-attachments/assets/36de8512-acfd-44fb-bb1f-b7c793a3f926" width="45" height="30"></a>
|
|
6
|
+
<a href="https://github.com/2captcha/2captcha-php"><img src="https://github.com/user-attachments/assets/e8797843-3f61-4fa9-a155-ab0b21fb3858" width="52" height="30"></a>
|
|
7
|
+
<a href="https://github.com/2captcha/2captcha-java"><img src="https://github.com/user-attachments/assets/a3d923f6-4fec-4c07-ac50-e20da6370911" width="50" height="30"></a>
|
|
8
|
+
<a href="https://github.com/2captcha/2captcha-csharp"><img src="https://github.com/user-attachments/assets/f4d449de-780b-49ed-bb0a-b70c82ec4b32" width="38" height="30"></a>
|
|
9
|
+
|
|
10
|
+
# JavaScript module for 2Captcha API (captcha solver)
|
|
2
11
|
|
|
3
12
|
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.
|
|
13
|
+
Examples of API requests for different captcha types are available on the [JavaScript captcha solver](https://2captcha.com/lang/javascript) page.
|
|
4
14
|
|
|
5
|
-
- [JavaScript
|
|
15
|
+
- [JavaScript module for 2Captcha API (captcha solver)](#javascript-module-for-2captcha-api-captcha-solver)
|
|
6
16
|
- [Installation](#installation)
|
|
7
17
|
- [Configuration](#configuration)
|
|
8
18
|
- [TwoCaptcha instance options](#twocaptcha-instance-options)
|
|
@@ -25,6 +35,7 @@ The easiest way to quickly integrate the [2Captcha](https://2captcha.com/) captc
|
|
|
25
35
|
- [MTCaptcha](#mtcaptcha)
|
|
26
36
|
- [Friendly Captcha](#friendly-captcha)
|
|
27
37
|
- [Bounding Box Method](#bounding-box-method)
|
|
38
|
+
- [Grid](#grid)
|
|
28
39
|
- [Other methods](#other-methods)
|
|
29
40
|
- [goodReport](#goodreport)
|
|
30
41
|
- [badReport](#badreport)
|
|
@@ -32,6 +43,8 @@ The easiest way to quickly integrate the [2Captcha](https://2captcha.com/) captc
|
|
|
32
43
|
- [Proxies](#proxies)
|
|
33
44
|
- [Examples](#examples)
|
|
34
45
|
- [Useful articles](#useful-articles)
|
|
46
|
+
- [Get in touch](#get-in-touch)
|
|
47
|
+
- [Join the team 👪](#join-the-team-)
|
|
35
48
|
|
|
36
49
|
|
|
37
50
|
## Installation
|
|
@@ -440,7 +453,7 @@ solver.coordinates({
|
|
|
440
453
|
})
|
|
441
454
|
```
|
|
442
455
|
|
|
443
|
-
### Bounding Box Method
|
|
456
|
+
### Bounding Box Method
|
|
444
457
|
|
|
445
458
|
<sup>[API method description.](https://2captcha.com/2captcha-api#bounding_box)</sup>
|
|
446
459
|
|
|
@@ -462,6 +475,28 @@ solver.boundingBox({
|
|
|
462
475
|
})
|
|
463
476
|
```
|
|
464
477
|
|
|
478
|
+
### Grid
|
|
479
|
+
|
|
480
|
+
<sup>[API method description.](https://2captcha.com/2captcha-api#grid)</sup>
|
|
481
|
+
|
|
482
|
+
This method allows to solve any captcha where image can be divided into equal parts like reCAPTCHA V2 or hCaptcha. A grid is applied above the image. And you receive the numbers clicked boxes.
|
|
483
|
+
|
|
484
|
+
> [!IMPORTANT]
|
|
485
|
+
> You must to send instruction `imginstructions` or `textinstructions`.
|
|
486
|
+
|
|
487
|
+
```js
|
|
488
|
+
solver.grid({
|
|
489
|
+
body: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAR4AAACwCAIAAAB...",
|
|
490
|
+
textinstructions: "Select cars in the image"
|
|
491
|
+
})
|
|
492
|
+
.then((res) => {
|
|
493
|
+
console.log(res);
|
|
494
|
+
})
|
|
495
|
+
.catch((err) => {
|
|
496
|
+
console.log(err);
|
|
497
|
+
})
|
|
498
|
+
```
|
|
499
|
+
|
|
465
500
|
## Other methods
|
|
466
501
|
|
|
467
502
|
### goodReport
|
|
@@ -524,9 +559,20 @@ Examples of solving all supported captcha types are located in the [examples] di
|
|
|
524
559
|
* [Custom Slider Captcha Demo](https://github.com/2captcha/custom-slider-demo)
|
|
525
560
|
* [Cloudflare Challenge page bypass code example](https://github.com/2captcha/cloudflare-demo)
|
|
526
561
|
|
|
562
|
+
## Get in touch
|
|
563
|
+
|
|
564
|
+
<a href="mailto:support@2captcha.com"><img src="https://github.com/user-attachments/assets/539df209-7c85-4fa5-84b4-fc22ab93fac7" width="80" height="30"></a>
|
|
565
|
+
<a href="https://2captcha.com/support/tickets/new"><img src="https://github.com/user-attachments/assets/be044db5-2e67-46c6-8c81-04b78bd99650" width="81" height="30"></a>
|
|
566
|
+
|
|
567
|
+
## Join the team 👪
|
|
568
|
+
|
|
569
|
+
There are many ways to contribute, of which development is only one! Find your next job. Open positions: AI experts, scrapers, developers, technical support, and much more! 😍
|
|
570
|
+
|
|
571
|
+
<a href="mailto:job@2captcha.com"><img src="https://github.com/user-attachments/assets/36d23ef5-7866-4841-8e17-261cc8a4e033" width="80" height="30"></a>
|
|
572
|
+
|
|
527
573
|
<!-- Shared links -->
|
|
528
574
|
[post options]: https://2captcha.com/2captcha-api#normal_post
|
|
529
575
|
[list of supported languages]: https://2captcha.com/2captcha-api#language
|
|
530
576
|
[Buy residential proxies]: https://2captcha.com/proxy/residential-proxies
|
|
531
577
|
[Quick start]: https://2captcha.com/proxy?openAddTrafficModal=true
|
|
532
|
-
[examples]: ./examples
|
|
578
|
+
[examples]: ./examples
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export interface paramsRecaptcha {
|
|
2
2
|
pageurl: string;
|
|
3
3
|
googlekey: string;
|
|
4
|
-
invisible?:
|
|
4
|
+
invisible?: 0 | 1;
|
|
5
5
|
datas?: string;
|
|
6
6
|
domain?: string;
|
|
7
7
|
cookies?: string;
|
|
@@ -192,6 +192,20 @@ export interface paramsBoundingBox {
|
|
|
192
192
|
textinstructions?: string;
|
|
193
193
|
imginstructions?: string;
|
|
194
194
|
}
|
|
195
|
+
export interface paramsGrid {
|
|
196
|
+
body: string;
|
|
197
|
+
recaptcha: 1;
|
|
198
|
+
rows?: number;
|
|
199
|
+
cols?: number;
|
|
200
|
+
minСlicks?: number;
|
|
201
|
+
maxСlicks?: number;
|
|
202
|
+
previousId?: string;
|
|
203
|
+
textinstructions?: string;
|
|
204
|
+
imginstructions?: string;
|
|
205
|
+
canSkip?: number;
|
|
206
|
+
lang?: string;
|
|
207
|
+
pingback?: string;
|
|
208
|
+
}
|
|
195
209
|
/**
|
|
196
210
|
* An object containing properties of the captcha solution.
|
|
197
211
|
* @typedef {Object} CaptchaAnswer
|
|
@@ -267,7 +281,7 @@ export declare class Solver {
|
|
|
267
281
|
* @param {string} params.datas Value of `data-s` parameter you found on page. Curenttly applicable for Google Search and other Google services.
|
|
268
282
|
* @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).
|
|
269
283
|
* @param {string} params.action Value of `action` parameter you found on page.
|
|
270
|
-
* @param {
|
|
284
|
+
* @param {number} params.enterprise `1` - defines that you're sending reCAPTCHA Enterpise.
|
|
271
285
|
* @param {number} params.min_score The score needed for resolution reCAPTCHA V3. Currently it's almost impossible to get token with score higher than `0.3`
|
|
272
286
|
* @param {string} params.version `v2` — defines that you're sending a reCAPTCHA V2. `v3` — defines that you're sending a reCAPTCHA V3.
|
|
273
287
|
* @param {string} params.domain Domain used to load the captcha: `google.com` or `recaptcha.net`
|
|
@@ -288,7 +302,7 @@ export declare class Solver {
|
|
|
288
302
|
*/
|
|
289
303
|
recaptcha(params: paramsRecaptcha): Promise<CaptchaAnswer>;
|
|
290
304
|
/**
|
|
291
|
-
* Solves a hCaptcha
|
|
305
|
+
* ### Solves a hCaptcha
|
|
292
306
|
*
|
|
293
307
|
* [Read more about other hCaptcha parameters](https://2captcha.com/2captcha-api#solving_hcaptcha).
|
|
294
308
|
*
|
|
@@ -318,7 +332,9 @@ export declare class Solver {
|
|
|
318
332
|
*/
|
|
319
333
|
hcaptcha(params: paramsHCaptcha): Promise<CaptchaAnswer>;
|
|
320
334
|
/**
|
|
321
|
-
* Solves a GeeTest Captcha.
|
|
335
|
+
* ### Solves a GeeTest Captcha.
|
|
336
|
+
*
|
|
337
|
+
* [Read more about parameters and solving for Geetest captcha](https://2captcha.com/2captcha-api#solving_geetest).
|
|
322
338
|
*
|
|
323
339
|
* @param {{ gt, challenge, api_server, offline, new_captcha,
|
|
324
340
|
* pageurl, pingback, proxy, proxytype, userAgent }} params
|
|
@@ -371,7 +387,6 @@ export declare class Solver {
|
|
|
371
387
|
/**
|
|
372
388
|
* ### Solves a GeeTest V4 Captcha.
|
|
373
389
|
*
|
|
374
|
-
*
|
|
375
390
|
* This method accepts an object with the following fields: `pageurl`, `captcha_id`, `pingback`, `proxy`, `proxytype`, `userAgent`.
|
|
376
391
|
* The `pageurl` and `captcha_id` fields are required.
|
|
377
392
|
*
|
|
@@ -399,7 +414,8 @@ export declare class Solver {
|
|
|
399
414
|
*/
|
|
400
415
|
geetestV4(params: paramsGeeTestV4): Promise<CaptchaAnswer>;
|
|
401
416
|
/**
|
|
402
|
-
* Method for sending Yandex Smart Captcha.
|
|
417
|
+
* ### Method for sending Yandex Smart Captcha.
|
|
418
|
+
*
|
|
403
419
|
* This method accepts an object with the following fields: `pageurl`, `sitekey`, `pingback`, `proxy`, `proxytype`.
|
|
404
420
|
* The `pageurl` and `sitekey` fields are required.
|
|
405
421
|
*
|
|
@@ -427,7 +443,9 @@ export declare class Solver {
|
|
|
427
443
|
*/
|
|
428
444
|
yandexSmart(params: yandexSmart): Promise<CaptchaAnswer>;
|
|
429
445
|
/**
|
|
430
|
-
* Solves a image-based captcha.
|
|
446
|
+
* ### Solves a image-based captcha.
|
|
447
|
+
*
|
|
448
|
+
* [Read more about parameters for image captcha](https://2captcha.com/2captcha-api#solving_normal_captcha).
|
|
431
449
|
*
|
|
432
450
|
* @param {{ body,
|
|
433
451
|
* phrase,
|
|
@@ -440,7 +458,7 @@ export declare class Solver {
|
|
|
440
458
|
* lang,
|
|
441
459
|
* textinstructions,
|
|
442
460
|
* pingback }} params Extra properties to pass to 2captcha.
|
|
443
|
-
* @param {
|
|
461
|
+
* @param {string} params.body Base64 image data for the captcha.
|
|
444
462
|
* @param {number} params.phrase Captcha contains two or more words? `1` - Yes. `0` - No.
|
|
445
463
|
* @param {number} params.regsense Captcha is case sensitive? `1` - Yes. `0` - No.
|
|
446
464
|
* @param {number} params.numeric `0` - not specified. `1` - captcha contains only numbers. `2` - captcha contains only letters. `3` - captcha contains only numbers OR only letters. `4` - captcha MUST contain both numbers AND letters.
|
|
@@ -620,16 +638,6 @@ export declare class Solver {
|
|
|
620
638
|
* })
|
|
621
639
|
*/
|
|
622
640
|
coordinates(params: paramsCoordinates): Promise<CaptchaAnswer>;
|
|
623
|
-
/**
|
|
624
|
-
* pageurl: string,
|
|
625
|
-
captchakey: string,
|
|
626
|
-
api_server?: string,
|
|
627
|
-
version?: string,
|
|
628
|
-
header_acao?: boolean,
|
|
629
|
-
pingback?: string,
|
|
630
|
-
proxy?: string,
|
|
631
|
-
proxytype?: string,
|
|
632
|
-
*/
|
|
633
641
|
/**
|
|
634
642
|
* ### Solves Capy Puzzle captcha
|
|
635
643
|
*
|
|
@@ -780,9 +788,9 @@ export declare class Solver {
|
|
|
780
788
|
* ### Bounding Box Method
|
|
781
789
|
*
|
|
782
790
|
* @param {{ image, textinstructions, imginstructions }} params Parameters Bounding Box Method as an object.
|
|
783
|
-
* @param {
|
|
784
|
-
* @param {
|
|
785
|
-
* @param {
|
|
791
|
+
* @param {string} params.image Image containing data for markup. The image must be encoded in `Base64` format.
|
|
792
|
+
* @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`.
|
|
793
|
+
* @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`.
|
|
786
794
|
*
|
|
787
795
|
* @example
|
|
788
796
|
* solver.boundingBox({
|
|
@@ -797,6 +805,38 @@ export declare class Solver {
|
|
|
797
805
|
* })
|
|
798
806
|
*/
|
|
799
807
|
boundingBox(params: paramsBoundingBox): Promise<CaptchaAnswer>;
|
|
808
|
+
/**
|
|
809
|
+
* ### Grid method
|
|
810
|
+
*
|
|
811
|
+
* 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.
|
|
812
|
+
*
|
|
813
|
+
* @param {{ body, textinstructions, imginstructions, rows, cols, minСlicks, maxСlicks, previousId, canSkip, lang, pingback}} params Parameters Grid Method as an object.
|
|
814
|
+
* @param {string} params.body `Base64`- encoded captcha image.
|
|
815
|
+
* @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`.
|
|
816
|
+
* @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`.
|
|
817
|
+
* @param {number} params.rows Number of rows in grid captcha.
|
|
818
|
+
* @param {number} params.cols Number of columns in grid captcdha.
|
|
819
|
+
* @param {number} params.minСlicks The minimum number of tiles that must be selected. Can't be more than `rows` * `cols`.
|
|
820
|
+
* @param {number} params.maxСlicks The maximum number of tiles that can be selected on the image.
|
|
821
|
+
* @param {string} params.previousId Id of your previous request with the same captcha challenge.
|
|
822
|
+
* @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.
|
|
823
|
+
* @param {string} params.lang Language code. [See the list of supported languages](https://2captcha.com/2captcha-api#language).
|
|
824
|
+
* @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).
|
|
825
|
+
*
|
|
826
|
+
* @example
|
|
827
|
+
* solver.grid({
|
|
828
|
+
* body: 'iVBORw0KGgoAAAANSUhEUgAAAcIA...',
|
|
829
|
+
* textinstructions: "Select cars in the image",
|
|
830
|
+
* imginstructions: '/9j/4AAQSkZJRgABAQEA...'
|
|
831
|
+
* })
|
|
832
|
+
* .then((res) => {
|
|
833
|
+
* console.log(res);
|
|
834
|
+
* })
|
|
835
|
+
* .catch((err) => {
|
|
836
|
+
* console.log(err);
|
|
837
|
+
* })
|
|
838
|
+
*/
|
|
839
|
+
grid(params: paramsGrid): Promise<CaptchaAnswer>;
|
|
800
840
|
/**
|
|
801
841
|
* Reports a captcha as correctly solved.
|
|
802
842
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"2captcha.d.ts","sourceRoot":"","sources":["../../src/struct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;;;;;;;OAqBG;IACU,eAAe,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,aAAa,CAAC;IA0B7E;;;;;;;;;;;;;;;;;;;OAmBG;IACU,WAAW,CAAC,MAAM,EAAE,iBAAiB,GAAG,OAAO,CAAC,aAAa,CAAC;IAgC3E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA8BG;IACU,IAAI,CAAC,MAAM,EAAE,UAAU,GAAG,OAAO,CAAC,aAAa,CAAC;IAkCzD;;;;;;;;OAQG;IACU,UAAU,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAwBlD;;;;;;;;;OASG;IACU,SAAS,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAuBpD"}
|
package/dist/structs/2captcha.js
CHANGED
|
@@ -33,6 +33,7 @@ const utils = __importStar(require("../utils/generic"));
|
|
|
33
33
|
const providers_1 = __importDefault(require("./providers/providers"));
|
|
34
34
|
const constants_1 = require("./constants/constants");
|
|
35
35
|
const checkCaptchaParams_1 = __importDefault(require("../utils/checkCaptchaParams"));
|
|
36
|
+
const renameParams_1 = __importDefault(require("../utils/renameParams"));
|
|
36
37
|
const provider = (0, providers_1.default)();
|
|
37
38
|
/**
|
|
38
39
|
* The main 2captcha class, housing all API calls and api interactions.
|
|
@@ -141,7 +142,7 @@ class Solver {
|
|
|
141
142
|
* @param {string} params.datas Value of `data-s` parameter you found on page. Curenttly applicable for Google Search and other Google services.
|
|
142
143
|
* @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).
|
|
143
144
|
* @param {string} params.action Value of `action` parameter you found on page.
|
|
144
|
-
* @param {
|
|
145
|
+
* @param {number} params.enterprise `1` - defines that you're sending reCAPTCHA Enterpise.
|
|
145
146
|
* @param {number} params.min_score The score needed for resolution reCAPTCHA V3. Currently it's almost impossible to get token with score higher than `0.3`
|
|
146
147
|
* @param {string} params.version `v2` — defines that you're sending a reCAPTCHA V2. `v3` — defines that you're sending a reCAPTCHA V3.
|
|
147
148
|
* @param {string} params.domain Domain used to load the captcha: `google.com` or `recaptcha.net`
|
|
@@ -184,7 +185,7 @@ class Solver {
|
|
|
184
185
|
}
|
|
185
186
|
}
|
|
186
187
|
/**
|
|
187
|
-
* Solves a hCaptcha
|
|
188
|
+
* ### Solves a hCaptcha
|
|
188
189
|
*
|
|
189
190
|
* [Read more about other hCaptcha parameters](https://2captcha.com/2captcha-api#solving_hcaptcha).
|
|
190
191
|
*
|
|
@@ -236,7 +237,9 @@ class Solver {
|
|
|
236
237
|
}
|
|
237
238
|
}
|
|
238
239
|
/**
|
|
239
|
-
* Solves a GeeTest Captcha.
|
|
240
|
+
* ### Solves a GeeTest Captcha.
|
|
241
|
+
*
|
|
242
|
+
* [Read more about parameters and solving for Geetest captcha](https://2captcha.com/2captcha-api#solving_geetest).
|
|
240
243
|
*
|
|
241
244
|
* @param {{ gt, challenge, api_server, offline, new_captcha,
|
|
242
245
|
* pageurl, pingback, proxy, proxytype, userAgent }} params
|
|
@@ -311,7 +314,6 @@ class Solver {
|
|
|
311
314
|
/**
|
|
312
315
|
* ### Solves a GeeTest V4 Captcha.
|
|
313
316
|
*
|
|
314
|
-
*
|
|
315
317
|
* This method accepts an object with the following fields: `pageurl`, `captcha_id`, `pingback`, `proxy`, `proxytype`, `userAgent`.
|
|
316
318
|
* The `pageurl` and `captcha_id` fields are required.
|
|
317
319
|
*
|
|
@@ -361,7 +363,8 @@ class Solver {
|
|
|
361
363
|
}
|
|
362
364
|
}
|
|
363
365
|
/**
|
|
364
|
-
* Method for sending Yandex Smart Captcha.
|
|
366
|
+
* ### Method for sending Yandex Smart Captcha.
|
|
367
|
+
*
|
|
365
368
|
* This method accepts an object with the following fields: `pageurl`, `sitekey`, `pingback`, `proxy`, `proxytype`.
|
|
366
369
|
* The `pageurl` and `sitekey` fields are required.
|
|
367
370
|
*
|
|
@@ -411,7 +414,9 @@ class Solver {
|
|
|
411
414
|
}
|
|
412
415
|
}
|
|
413
416
|
/**
|
|
414
|
-
* Solves a image-based captcha.
|
|
417
|
+
* ### Solves a image-based captcha.
|
|
418
|
+
*
|
|
419
|
+
* [Read more about parameters for image captcha](https://2captcha.com/2captcha-api#solving_normal_captcha).
|
|
415
420
|
*
|
|
416
421
|
* @param {{ body,
|
|
417
422
|
* phrase,
|
|
@@ -424,7 +429,7 @@ class Solver {
|
|
|
424
429
|
* lang,
|
|
425
430
|
* textinstructions,
|
|
426
431
|
* pingback }} params Extra properties to pass to 2captcha.
|
|
427
|
-
* @param {
|
|
432
|
+
* @param {string} params.body Base64 image data for the captcha.
|
|
428
433
|
* @param {number} params.phrase Captcha contains two or more words? `1` - Yes. `0` - No.
|
|
429
434
|
* @param {number} params.regsense Captcha is case sensitive? `1` - Yes. `0` - No.
|
|
430
435
|
* @param {number} params.numeric `0` - not specified. `1` - captcha contains only numbers. `2` - captcha contains only letters. `3` - captcha contains only numbers OR only letters. `4` - captcha MUST contain both numbers AND letters.
|
|
@@ -747,16 +752,6 @@ class Solver {
|
|
|
747
752
|
throw new _2captchaError_1.APIError(data.request);
|
|
748
753
|
}
|
|
749
754
|
}
|
|
750
|
-
/**
|
|
751
|
-
* pageurl: string,
|
|
752
|
-
captchakey: string,
|
|
753
|
-
api_server?: string,
|
|
754
|
-
version?: string,
|
|
755
|
-
header_acao?: boolean,
|
|
756
|
-
pingback?: string,
|
|
757
|
-
proxy?: string,
|
|
758
|
-
proxytype?: string,
|
|
759
|
-
*/
|
|
760
755
|
/**
|
|
761
756
|
* ### Solves Capy Puzzle captcha
|
|
762
757
|
*
|
|
@@ -1039,9 +1034,9 @@ class Solver {
|
|
|
1039
1034
|
* ### Bounding Box Method
|
|
1040
1035
|
*
|
|
1041
1036
|
* @param {{ image, textinstructions, imginstructions }} params Parameters Bounding Box Method as an object.
|
|
1042
|
-
* @param {
|
|
1043
|
-
* @param {
|
|
1044
|
-
* @param {
|
|
1037
|
+
* @param {string} params.image Image containing data for markup. The image must be encoded in `Base64` format.
|
|
1038
|
+
* @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`.
|
|
1039
|
+
* @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`.
|
|
1045
1040
|
*
|
|
1046
1041
|
* @example
|
|
1047
1042
|
* solver.boundingBox({
|
|
@@ -1083,6 +1078,67 @@ class Solver {
|
|
|
1083
1078
|
throw new _2captchaError_1.APIError(data.request);
|
|
1084
1079
|
}
|
|
1085
1080
|
}
|
|
1081
|
+
/**
|
|
1082
|
+
* ### Grid method
|
|
1083
|
+
*
|
|
1084
|
+
* 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.
|
|
1085
|
+
*
|
|
1086
|
+
* @param {{ body, textinstructions, imginstructions, rows, cols, minСlicks, maxСlicks, previousId, canSkip, lang, pingback}} params Parameters Grid Method as an object.
|
|
1087
|
+
* @param {string} params.body `Base64`- encoded captcha image.
|
|
1088
|
+
* @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`.
|
|
1089
|
+
* @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`.
|
|
1090
|
+
* @param {number} params.rows Number of rows in grid captcha.
|
|
1091
|
+
* @param {number} params.cols Number of columns in grid captcdha.
|
|
1092
|
+
* @param {number} params.minСlicks The minimum number of tiles that must be selected. Can't be more than `rows` * `cols`.
|
|
1093
|
+
* @param {number} params.maxСlicks The maximum number of tiles that can be selected on the image.
|
|
1094
|
+
* @param {string} params.previousId Id of your previous request with the same captcha challenge.
|
|
1095
|
+
* @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.
|
|
1096
|
+
* @param {string} params.lang Language code. [See the list of supported languages](https://2captcha.com/2captcha-api#language).
|
|
1097
|
+
* @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).
|
|
1098
|
+
*
|
|
1099
|
+
* @example
|
|
1100
|
+
* solver.grid({
|
|
1101
|
+
* body: 'iVBORw0KGgoAAAANSUhEUgAAAcIA...',
|
|
1102
|
+
* textinstructions: "Select cars in the image",
|
|
1103
|
+
* imginstructions: '/9j/4AAQSkZJRgABAQEA...'
|
|
1104
|
+
* })
|
|
1105
|
+
* .then((res) => {
|
|
1106
|
+
* console.log(res);
|
|
1107
|
+
* })
|
|
1108
|
+
* .catch((err) => {
|
|
1109
|
+
* console.log(err);
|
|
1110
|
+
* })
|
|
1111
|
+
*/
|
|
1112
|
+
async grid(params) {
|
|
1113
|
+
(0, checkCaptchaParams_1.default)(params, "grid");
|
|
1114
|
+
params = await (0, renameParams_1.default)(params);
|
|
1115
|
+
const payload = {
|
|
1116
|
+
...params,
|
|
1117
|
+
method: "base64",
|
|
1118
|
+
recaptcha: 1,
|
|
1119
|
+
...this.defaultPayload,
|
|
1120
|
+
};
|
|
1121
|
+
const URL = this.in;
|
|
1122
|
+
const response = await (0, fetch_1.default)(URL, {
|
|
1123
|
+
body: JSON.stringify(payload),
|
|
1124
|
+
method: "post",
|
|
1125
|
+
headers: { 'Content-Type': 'application/json' }
|
|
1126
|
+
});
|
|
1127
|
+
const result = await response.text();
|
|
1128
|
+
let data;
|
|
1129
|
+
try {
|
|
1130
|
+
data = JSON.parse(result);
|
|
1131
|
+
}
|
|
1132
|
+
catch {
|
|
1133
|
+
throw new _2captchaError_1.APIError(result);
|
|
1134
|
+
}
|
|
1135
|
+
if (data.status == 1) {
|
|
1136
|
+
return this.pollResponse(data.request);
|
|
1137
|
+
}
|
|
1138
|
+
else {
|
|
1139
|
+
throw new _2captchaError_1.APIError(data.request);
|
|
1140
|
+
}
|
|
1141
|
+
}
|
|
1086
1142
|
/**
|
|
1087
1143
|
* Reports a captcha as correctly solved.
|
|
1088
1144
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checkCaptchaParams.d.ts","sourceRoot":"","sources":["../../src/utils/checkCaptchaParams.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"checkCaptchaParams.d.ts","sourceRoot":"","sources":["../../src/utils/checkCaptchaParams.ts"],"names":[],"mappings":"AAyFA;;;;;GAKG;AACH,MAAM,CAAC,OAAO,UAAU,kBAAkB,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,uBAyCxE"}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
// Captcha methods for which parameter checking is available
|
|
4
4
|
const supportedMethods = ["userrecaptcha", "hcaptcha", "geetest", "geetest_v4", "yandex", "funcaptcha", "lemin", "amazon_waf",
|
|
5
|
-
"turnstile", "base64", "capy", "datadome", "cybersiara", "mt_captcha", "bounding_box", 'friendly_captcha'];
|
|
5
|
+
"turnstile", "base64", "capy", "datadome", "cybersiara", "mt_captcha", "bounding_box", 'friendly_captcha', 'grid'];
|
|
6
6
|
// Names of required fields that must be contained in the parameters captcha
|
|
7
7
|
const recaptchaRequiredFields = ['pageurl', 'googlekey'];
|
|
8
8
|
const hcaptchaRequiredFields = ['pageurl', 'sitekey'];
|
|
@@ -21,6 +21,7 @@ const сyberSiARARequiredFields = ['pageurl', 'master_url_id', 'userAgent'];
|
|
|
21
21
|
const mtСaptchaRequiredFields = ['pageurl', 'sitekey'];
|
|
22
22
|
const boundingBoxRequiredFields = ['image']; // and textinstructions or imginstructions
|
|
23
23
|
const friendlyCaptchaFields = ['pageurl', 'sitekey'];
|
|
24
|
+
const gridRequiredFields = ['body']; // and textinstructions or imginstructions
|
|
24
25
|
/**
|
|
25
26
|
* Getting required arguments for a captcha.
|
|
26
27
|
*
|
|
@@ -60,6 +61,9 @@ const getRequiredFildsArr = (method) => {
|
|
|
60
61
|
case "base64":
|
|
61
62
|
requiredFieldsArr = base64RequiredFields;
|
|
62
63
|
break;
|
|
64
|
+
case "grid":
|
|
65
|
+
requiredFieldsArr = gridRequiredFields;
|
|
66
|
+
break;
|
|
63
67
|
case "capy":
|
|
64
68
|
requiredFieldsArr = capyPuzzleRequiredFields;
|
|
65
69
|
break;
|
|
@@ -111,7 +115,16 @@ function checkCaptchaParams(params, method) {
|
|
|
111
115
|
}
|
|
112
116
|
else {
|
|
113
117
|
isCorrectCaptchaParams = false;
|
|
114
|
-
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
|
|
118
|
+
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.`);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
if (method === "grid") {
|
|
122
|
+
if (params.hasOwnProperty('textinstructions') || params.hasOwnProperty('imginstructions')) {
|
|
123
|
+
isCorrectCaptchaParams = true;
|
|
124
|
+
}
|
|
125
|
+
else {
|
|
126
|
+
isCorrectCaptchaParams = false;
|
|
127
|
+
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.`);
|
|
115
128
|
}
|
|
116
129
|
}
|
|
117
130
|
return isCorrectCaptchaParams;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* ### Renaming captcha parameters
|
|
4
|
+
*
|
|
5
|
+
* Description: parameter names used in the API may differ from those used in the library, in such cases parameter names are renamed in accordance with those used in the API.
|
|
6
|
+
*
|
|
7
|
+
* @param params - captcha parameters as an object
|
|
8
|
+
* @returns returns new object with renamed params
|
|
9
|
+
*
|
|
10
|
+
*/
|
|
11
|
+
export default function renameParams(params: any): any;
|
|
12
|
+
//# sourceMappingURL=renameParams.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"renameParams.d.ts","sourceRoot":"","sources":["../../src/utils/renameParams.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,MAAM,CAAC,OAAO,UAAU,YAAY,CAAC,MAAM,EAAE,GAAG,OAwB/C"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
/**
|
|
4
|
+
*
|
|
5
|
+
* ### Renaming captcha parameters
|
|
6
|
+
*
|
|
7
|
+
* Description: parameter names used in the API may differ from those used in the library, in such cases parameter names are renamed in accordance with those used in the API.
|
|
8
|
+
*
|
|
9
|
+
* @param params - captcha parameters as an object
|
|
10
|
+
* @returns returns new object with renamed params
|
|
11
|
+
*
|
|
12
|
+
*/
|
|
13
|
+
function renameParams(params) {
|
|
14
|
+
let newParams = new Object();
|
|
15
|
+
/**
|
|
16
|
+
* Captcha parameters that need to be renamed before sent to the API.
|
|
17
|
+
*/
|
|
18
|
+
const replaceParams = {
|
|
19
|
+
"cols": "recaptchacols",
|
|
20
|
+
"rows": "recaptcharows",
|
|
21
|
+
"minClicks": "min_clicks",
|
|
22
|
+
"maxClicks": "max_clicks",
|
|
23
|
+
"canSkip": "can_no_answer",
|
|
24
|
+
"previousId": "previousID"
|
|
25
|
+
};
|
|
26
|
+
for (let key in params) {
|
|
27
|
+
if (replaceParams.hasOwnProperty(key)) {
|
|
28
|
+
newParams[replaceParams[key]] = params[key];
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
newParams[key] = params[key];
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return newParams;
|
|
35
|
+
}
|
|
36
|
+
exports.default = renameParams;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@2captcha/captcha-solver",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.1",
|
|
4
4
|
"description": "JavaScript library for easy integration with the API of 2captcha captcha solving service to bypass reCAPTCHA, hCaptcha, funcaptcha, geetest and solve any other captchas.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"repository": {
|