@2captcha/captcha-solver 1.0.2 → 1.0.4

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 CHANGED
@@ -1,69 +1,123 @@
1
1
  # JavaScript captcha solver module for 2Captcha API
2
2
 
3
- ## Description
4
- A wrapper around the [2captcha](https://2captcha.com/) API. This wrapper supports any captcha bypass: reCAPTCHA V2, reCAPTCHA V3, hCaptcha, Arkose Labs FunCaptcha, image captcha, Coordinates (Click Captcha), Geetest, Geetest V4, Yandex Smart Captcha, Lemin captcha, Amazon WAF, Cloudflare Turnstile, Capy Puzzle, DataDome CAPTCHA, CyberSiARA, MTCaptcha, Friendly Captcha.
5
-
6
- Also added support for the `bounding_box` method. The Bounding Box Method allows you to mark data on the image. This method can be used to mark up datasets or highlight any objects in an image according to the given instructions. Read more about using *Bounding Box Method* on [documentation](https://2captcha.com/2captcha-api#bounding_box).
7
-
8
- [2captcha](https://2captcha.com/) is a service that solves many different types of captchas, this library serves as a wrapper around API 2captcha to bring easy, promise-based functionality to Node.js. This library specializes in concurrent solves, and Bulk API usage.
9
-
10
- - [Install](#install)
11
- - [Configuration](#configuration)
12
- - [Solve captcha](#solve-captcha)
13
- - [reCAPTCHA v2](#recaptcha-v2)
14
- - [reCAPTCHA v3](#recaptcha-v3)
15
- - [hCaptcha](#hcaptcha)
16
- - [Arkose Labs FunCaptcha](#arkose-labs-funcaptcha)
17
- - [Image captchas](#image-captcha) (`base64` format)
18
- - [GeeTest](#geetest-captcha)
19
- - [GeeTest V4](#geetest-v4-captcha)
20
- - [Yandex Smart Captcha](#yandex-smart-captcha)
21
- - [Lemin Cropped Captcha](#lemin-captcha)
22
- - [Cloudflare Turnstile](#cloudflare-turnstile)
23
- - [Amazon WAF Captcha](#amazon-waf-captcha)
24
- - [Capy Puzzle](#capy-puzzle)
25
- - [Coordinates (Click Captcha)](#coordinates-captcha)
26
- - [DataDome CAPTCHA](#datadome-captcha)
27
- - [CyberSiARA](#cybersiara)
28
- - [MTCaptcha](#mtcaptcha)
29
- - [Friendly Captcha](#friendly-captcha)
30
- - [Bounding Box Method](#bounding-box-method)
31
- - [Usage of proxy](#usage-of-proxy)
32
- - [Other methods](#other-methods)
33
- - [badReport](#badreport)
34
- - [goodReport](#goodreport)
35
- - [balance](#balance)
36
- - [Proxies](#proxies)
37
- - [Useful articles](#useful-articles)
38
- - [How to bypass Geetest v4 CAPTCHA](https://2captcha.com/blog/geetest-v4-support)
39
- - [Automatic reCAPTCHA V3 resolution - a tutorial for developers and customers](https://2captcha.com/blog/recaptcha-v3-automatic-resolution)
40
- - Finding Sitekey <a href="./docs/hcaptcha.md">hCaptcha</a>
41
-
42
-
43
- ## Install
3
+ 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.
4
+
5
+ - [JavaScript captcha solver module for 2Captcha API](#javascript-captcha-solver-module-for-2captcha-api)
6
+ - [Installation](#installation)
7
+ - [Configuration](#configuration)
8
+ - [TwoCaptcha instance options](#twocaptcha-instance-options)
9
+ - [Solve captcha](#solve-captcha)
10
+ - [Image captchas](#image-captcha)
11
+ - [reCAPTCHA v2](#recaptcha-v2)
12
+ - [reCAPTCHA v3](#recaptcha-v3)
13
+ - [hCaptcha](#hcaptcha)
14
+ - [FunCaptcha](#funcaptcha)
15
+ - [GeeTest](#geetest-captcha)
16
+ - [GeeTest V4](#geetest-v4-captcha)
17
+ - [Yandex Smart Captcha](#yandex-smart-captcha)
18
+ - [Lemin Cropped Captcha](#lemin-cropped-captcha)
19
+ - [Cloudflare Turnstile](#cloudflare-turnstile)
20
+ - [Amazon WAF](#amazon-waf)
21
+ - [Capy](#capy)
22
+ - [ClickCaptcha](#clickcaptcha)
23
+ - [DataDome CAPTCHA](#datadome-captcha)
24
+ - [CyberSiARA](#cybersiara)
25
+ - [MTCaptcha](#mtcaptcha)
26
+ - [Friendly Captcha](#friendly-captcha)
27
+ - [Bounding Box Method](#bounding-box-method)
28
+ - [Other methods](#other-methods)
29
+ - [goodReport](#goodreport)
30
+ - [badReport](#badreport)
31
+ - [balance](#balance)
32
+ - [Proxies](#proxies)
33
+ - [Examples](#examples)
34
+ - [Useful articles](#useful-articles)
35
+
36
+
37
+ ## Installation
38
+ This package can be installed with NPM:
44
39
 
45
40
  ```sh
46
41
  npm install @2captcha/captcha-solver
47
42
  ```
48
- or
43
+ or Yarn:
49
44
  ```sh
50
45
  yarn add @2captcha/captcha-solver
51
46
  ```
52
47
 
53
48
  ## Configuration
54
49
 
55
- Instance can be created like this:
50
+ TwoCaptcha instance can be created like this:
56
51
 
57
52
  ```js
58
- const Captcha = require("@2captcha/captcha-solver")
59
- const solver = new Captcha.Solver("<Your 2captcha api key>")
53
+ const TwoCaptcha = require("@2captcha/captcha-solver")
54
+ const solver = new TwoCaptcha.Solver("<Your 2captcha api key>")
60
55
  ```
61
56
 
57
+ Also, there are a few options that can be configured:
58
+
59
+ ```javascript
60
+ const apiKey = 'YOUR_API_KEY'
61
+ const pollingInterval = 10
62
+
63
+ const solver = new TwoCaptcha.Solver(apiKey, pollingInterval)
64
+ ```
65
+ ### TwoCaptcha instance options
66
+
67
+ | Option | Default value | Description |
68
+ | ---------------- | -------------- | -------------------------------------------------------------------------------------------- |
69
+ | apiKey | - | Your API key |
70
+ | pollingInterval | 5000 | Interval in milliseconds between requests to the `res.php` API endpoint. Setting values less than 5 seconds is not recommended |
71
+
62
72
  ## Solve captcha
63
73
 
74
+ When you submit any image-based captcha use can provide additional options to help 2captcha workers to solve it properly.
75
+
76
+ ### Captcha options
77
+
78
+ | Option | Default Value | Description |
79
+ | ------------- | ------------- | -------------------------------------------------------------------------------------------------- |
80
+ | numeric | 0 | Defines if the captcha contains numeric or other symbols [see more info in the API docs][post options] |
81
+ | min_len | 0 | minimal answer length |
82
+ | max_len | 0 | maximum answer length |
83
+ | phrase | 0 | defines if the answer contains multiple words or not |
84
+ | regsense | 0 | defines if the answer is case sensitive |
85
+ | calc | 0 | defines captcha requires calculation |
86
+ | lang | - | defines the captcha language; see the [list of supported languages] |
87
+ | textinstructions| - | hint or task text shown to workers with the captcha |
88
+
89
+ Below you can find basic examples for every captcha type, check out the code below.
90
+
91
+ ### Image captcha
92
+
93
+ <sup>[API method description.](https://2captcha.com/2captcha-api#solving_normal_captcha)</sup>
94
+
95
+ 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.
96
+
97
+ ```js
98
+ // Read from a file as base64 text
99
+ const imageBase64 = fs.readFileSync("./examples/media/imageCaptcha_6e584.png", "base64")
100
+
101
+ solver.imageCaptcha({
102
+ body: imageBase64,
103
+ numeric: 4,
104
+ min_len: 5,
105
+ max_len: 5
106
+ })
107
+ .then((res) => {
108
+ // Logs the image text
109
+ console.log(res);
110
+ })
111
+ .catch((err) => {
112
+ console.log(err);
113
+ })
114
+ ```
115
+
64
116
  ### reCAPTCHA V2
65
117
 
66
- Use this method to solve reCAPTCHA V2 and obtain a token to bypass the protection.
118
+ <sup>[API method description.](https://2captcha.com/2captcha-api#solving_recaptchav2_new)</sup>
119
+
120
+ Use the following method to solve reCAPTCHA V2 and obtain a token to bypass the protection.
67
121
 
68
122
  ```js
69
123
  solver.recaptcha({
@@ -80,7 +134,9 @@ solver.recaptcha({
80
134
 
81
135
  ### reCAPTCHA V3
82
136
 
83
- This method provides reCAPTCHA V3 solver and returns a token.
137
+ <sup>[API method description.](https://2captcha.com/2captcha-api#solving_recaptchav3)</sup>
138
+
139
+ This method provides a reCAPTCHA V3 solver and returns a token.
84
140
 
85
141
  ```js
86
142
  solver.recaptcha({
@@ -101,7 +157,9 @@ solver.recaptcha({
101
157
 
102
158
  ### hCaptcha
103
159
 
104
- Use this method to solve hCaptcha challenge. Returns a token to bypass captcha.
160
+ <sup>[API method description.](https://2captcha.com/2captcha-api#solving_hcaptcha)</sup>
161
+
162
+ Use this method to solve the hCaptcha challenge. Returns a token to bypass the captcha.
105
163
 
106
164
  ```js
107
165
  solver.hcaptcha({
@@ -116,7 +174,9 @@ solver.hcaptcha({
116
174
  })
117
175
  ```
118
176
 
119
- ### Arkose Labs FunCaptcha
177
+ ### FunCaptcha
178
+
179
+ <sup>[API method description.](https://2captcha.com/2captcha-api#solving_funcaptcha_new)</sup>
120
180
 
121
181
  FunCaptcha (Arkoselabs) solving method. Returns a token.
122
182
 
@@ -133,32 +193,10 @@ solver.funCaptcha({
133
193
  })
134
194
  ```
135
195
 
136
- ### Image captcha
137
-
138
- To bypass a normal captcha (distorted text on image) use this method. This method also can be used to recognize any text on the image.
139
-
140
- ```js
141
- // Read from a file as base64 text
142
- const imageBase64 = fs.readFileSync("./tests/media/imageCaptcha_6e584.png", "base64")
143
-
144
- solver.imageCaptcha({
145
- body: imageBase64,
146
- numeric: 4,
147
- min_len: 5,
148
- max_len: 5
149
- })
150
- .then((res) => {
151
- // Logs the image text
152
- console.log(res);
153
- })
154
- .catch((err) => {
155
- console.log(err);
156
- })
157
- ```
158
-
159
-
160
196
  ### GeeTest Captcha
161
197
 
198
+ <sup>[API method description.](https://2captcha.com/2captcha-api#solving_geetest)</sup>
199
+
162
200
  Method to solve GeeTest puzzle captcha. Returns a set of tokens as JSON.
163
201
 
164
202
  ```js
@@ -178,7 +216,9 @@ solver.geetest({
178
216
 
179
217
  ### GeeTest V4 Captcha
180
218
 
181
- Method to solve GeeTest V4 puzzle captcha. Returns a set of tokens as JSON.
219
+ <sup>[API method description.](https://2captcha.com/2captcha-api#geetest-v4)</sup>
220
+
221
+ Use this method to solve GeeTest v4. Returns the response in JSON.
182
222
 
183
223
  ```js
184
224
  solver.geetestV4({
@@ -210,9 +250,11 @@ solver.yandexSmart({
210
250
  })
211
251
  ```
212
252
 
213
- ### Lemin captcha
253
+ ### Lemin Cropped Captcha
214
254
 
215
- Use this method to solve Lemin captcha and obtain a token to bypass the protection.
255
+ <sup>[API method description.](https://2captcha.com/2captcha-api#lemin)</sup>
256
+
257
+ Use this method to solve Lemin and obtain a token to bypass the protection.
216
258
 
217
259
  ```js
218
260
  solver.lemin({
@@ -231,7 +273,11 @@ solver.lemin({
231
273
 
232
274
  ### Cloudflare Turnstile
233
275
 
234
- Use this method to solve Turnstile and obtain a token to bypass the protection.
276
+ <sup>[API method description.](https://2captcha.com/2captcha-api#turnstile)</sup>
277
+
278
+ Use this method to solve Cloudflare Turnstile. Returns JSON with the token.
279
+
280
+ Turnstile captcha has two types, one of them is Cloudflare Turnstile Challenge page. For Turnstile Challenge page cases, we have a [demo](https://github.com/2captcha/cloudflare-demo). Try this [demo](https://github.com/2captcha/cloudflare-demo) if you need to solve Cloudflare Turnstile Challenge page captcha.
235
281
 
236
282
  ```js
237
283
  solver.cloudflareTurnstile({
@@ -246,9 +292,11 @@ solver.cloudflareTurnstile({
246
292
  })
247
293
  ```
248
294
 
249
- <h3 id="amazon-waf-captcha">Amazon WAF Captcha (AWS WAF):</h3>
295
+ ### Amazon WAF
250
296
 
251
- Use this method to solve AmazonWaf and obtain a token to bypass the protection.
297
+ <sup>[API method description.](https://2captcha.com/2captcha-api#amazon-waf)</sup>
298
+
299
+ Use this method to solve Amazon WAF Captcha also known as AWS WAF Captcha is a part of Intelligent threat mitigation for Amazon AWS. Returns JSON with the token.
252
300
 
253
301
  ```js
254
302
  //INFO: The `context` value is dynamic, it is necessary to take the actual value from the page each time.
@@ -266,7 +314,9 @@ solver.amazonWaf({
266
314
  })
267
315
  ```
268
316
 
269
- ### Capy Puzzle
317
+ ### Capy
318
+
319
+ <sup>[API method description.](https://2captcha.com/2captcha-api#solving_capy)</sup>
270
320
 
271
321
  Token-based method to bypass Capy puzzle captcha.
272
322
 
@@ -285,10 +335,12 @@ solver.capyPuzzle({
285
335
 
286
336
  ### DataDome CAPTCHA
287
337
 
338
+ <sup>[API method description.](https://2captcha.com/2captcha-api#datadome)</sup>
339
+
288
340
  Use this method to solve DataDome and obtain a token to bypass the protection.
289
341
 
290
342
  > [!IMPORTANT]
291
- > To solve the DataDome captcha, you must use a proxy. It is recommended to use mobile residential proxies.
343
+ > To solve the DataDome captcha, you must use a proxy. It is recommended to use [residential proxies][Buy residential proxies].
292
344
 
293
345
  ```js
294
346
  solver.dataDome({
@@ -308,6 +360,8 @@ console.log(err);
308
360
 
309
361
  ### CyberSiARA
310
362
 
363
+ <sup>[API method description.](https://2captcha.com/2captcha-api#cybersiara)</sup>
364
+
311
365
  Use this method to solve CyberSiARA and obtain a token to bypass the protection.
312
366
 
313
367
  ```js
@@ -326,6 +380,8 @@ console.log(err);
326
380
 
327
381
  ### MTCaptcha
328
382
 
383
+ <sup>[API method description.](https://2captcha.com/2captcha-api#mtcaptcha)</sup>
384
+
329
385
  Use this method to solve MTCaptcha and obtain a token to bypass the protection.
330
386
 
331
387
  ```js
@@ -343,8 +399,12 @@ console.log(err);
343
399
 
344
400
  ### Friendly Captcha
345
401
 
402
+ <sup>[API method description.](https://2captcha.com/2captcha-api#friendly-captcha)</sup>
403
+
346
404
  Use this method to solve Friendly Captcha and obtain a token to bypass the protection.
347
- > **Important:** To successfully use the received token, the captcha widget must not be loaded on the page. To do this, you need to abort request to `/friendlycaptcha/...module.min.js` on the page. When the captcha widget is already loaded on the page, there is a high probability that the received token will not work.
405
+
406
+ > [!IMPORTANT]
407
+ > To successfully use the received token, the captcha widget must not be loaded on the page. To do this, you need to abort request to `/friendlycaptcha/...module.min.js` on the page. When the captcha widget is already loaded on the page, there is a high probability that the received token will not work.
348
408
 
349
409
  ```js
350
410
  solver.friendlyCaptcha({
@@ -359,9 +419,11 @@ console.log(err);
359
419
  })
360
420
  ```
361
421
 
362
- <h3 id="coordinates-captcha">Coordinates (Click Captcha):</h3>
422
+ ### ClickCaptcha
363
423
 
364
- ClickCaptcha method returns coordinates of points on captcha image. Can be used if you need to click on particular points on the image.
424
+ <sup>[API method description.](https://2captcha.com/2captcha-api#coordinates)</sup>
425
+
426
+ The ClickCaptcha method returns the coordinates of points on the captcha image. It can be used if you need to click on particular points in the image.
365
427
 
366
428
  ```js
367
429
  const imageBase64 = fs.readFileSync("./tests/media/hCaptchaImage.jpg", "base64")
@@ -380,7 +442,12 @@ solver.coordinates({
380
442
 
381
443
  ### Bounding Box Method:
382
444
 
383
- Bounding Box Method allows you to select objects specified in the image. To do this, you need to pass markup instructions. The instructions can be sent as text or as an image encoded in `base64` format. It is mandatory to pass at least one instruction `imginstructions` or `textinstructions`.
445
+ <sup>[API method description.](https://2captcha.com/2captcha-api#bounding_box)</sup>
446
+
447
+
448
+ Use Bounding Box Method when you need to select objects on the image. To do this, you need to pass the markup instructions and image for markup. The instructions can be sent as text or as an image encoded in `base64` format.
449
+ > [!IMPORTANT]
450
+ > You must to send instruction `imginstructions` or `textinstructions`.
384
451
 
385
452
  ```js
386
453
  solver.boundingBox({
@@ -395,29 +462,12 @@ solver.boundingBox({
395
462
  })
396
463
  ```
397
464
 
398
- ### Usage of proxy
399
-
400
- Solving reCAPTCHA V2 whis a proxy, code example:
401
-
402
- ```js
403
- solver.recaptcha({
404
- pageurl: 'https://2captcha.com/demo/recaptcha-v2',
405
- googlekey: '6LfD3PIbAAAAAJs_eEHvoOl75_83eXSqpPSRFJ_u',
406
- proxy: "login:password@1.2.3.4:8888", // The (Username : Password @ Address : Port) of our chosen proxy
407
- proxytype: "http" // The 'Type' of proxy, http, https, socks4, socks5.
408
- })
409
- .then((res) => {
410
- console.log(res)
411
- })
412
- .catch((err) => {
413
- console.error(err.message)
414
- })
415
- ```
416
-
417
465
  ## Other methods
418
466
 
419
467
  ### goodReport
420
468
 
469
+ <sup>[API method description.](https://2captcha.com/2captcha-api#reporting-answers)</sup>
470
+
421
471
  Use this method to report good captcha answer.
422
472
 
423
473
  ```js
@@ -426,6 +476,8 @@ solver.goodReport('7031846604')
426
476
 
427
477
  ### badReport
428
478
 
479
+ <sup>[API method description.](https://2captcha.com/2captcha-api#reporting-answers)</sup>
480
+
429
481
  Use this method to report bad captcha answer.
430
482
 
431
483
  ```js
@@ -434,7 +486,9 @@ solver.badReport('7031854546')
434
486
 
435
487
  ### balance
436
488
 
437
- Use this method to get your account's balance
489
+ <sup>[API method description.](https://2captcha.com/2captcha-api#additional-methods)</sup>
490
+
491
+ Use this method to get your account's balance.
438
492
 
439
493
  ```js
440
494
  solver.balance()
@@ -458,13 +512,21 @@ solver.recaptcha({
458
512
  proxytype: 'login:password@123.123.123.123:3128'
459
513
  })
460
514
  ```
515
+ ## Examples
461
516
 
517
+ Examples of solving all supported captcha types are located in the [examples] directory.
462
518
 
463
519
  ## Useful articles
520
+ * [How to bypass captcha using JavaScript](https://2captcha.com/blog/how-to-use-javascript-to-bypass-captcha#how-to-solve-and-bypass-a-captcha-with-javascript-using-npm-package-2captchacaptcha-solver)
521
+ * [Bypassing Cloudflare Challenge with Puppeteer and 2Captcha](https://2captcha.com/blog/bypassing-cloudflare-challenge-with-puppeteer-and-2captcha)
464
522
  * [How to bypass Geetest v4 CAPTCHA](https://2captcha.com/blog/geetest-v4-support)
465
523
  * [Automatic reCAPTCHA V3 resolution - a tutorial for developers and customers](https://2captcha.com/blog/recaptcha-v3-automatic-resolution)
466
- * Finding Sitekey <a href="./docs/hcaptcha.md">hCaptcha</a>
524
+ * [Custom Slider Captcha Demo](https://github.com/2captcha/custom-slider-demo)
525
+ * [Cloudflare Challenge page bypass code example](https://github.com/2captcha/cloudflare-demo)
467
526
 
468
527
  <!-- Shared links -->
528
+ [post options]: https://2captcha.com/2captcha-api#normal_post
529
+ [list of supported languages]: https://2captcha.com/2captcha-api#language
469
530
  [Buy residential proxies]: https://2captcha.com/proxy/residential-proxies
470
- [Quick start]: https://2captcha.com/proxy?openAddTrafficModal=true
531
+ [Quick start]: https://2captcha.com/proxy?openAddTrafficModal=true
532
+ [examples]: ./examples
@@ -0,0 +1,3 @@
1
+ export { Solver } from "./structs/2captcha";
2
+ export { APIError } from "./structs/2captchaError";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAA;AAC3C,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAA"}
package/dist/index.js ADDED
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.APIError = exports.Solver = void 0;
4
+ var _2captcha_1 = require("./structs/2captcha");
5
+ Object.defineProperty(exports, "Solver", { enumerable: true, get: function () { return _2captcha_1.Solver; } });
6
+ var _2captchaError_1 = require("./structs/2captchaError");
7
+ Object.defineProperty(exports, "APIError", { enumerable: true, get: function () { return _2captchaError_1.APIError; } });
8
+ // export { Server } from "./structs/2captchaServer.js"