@2captcha/captcha-solver 1.0.3 → 1.1.0

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,124 @@
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
+ - [Grid](#grid)
29
+ - [Other methods](#other-methods)
30
+ - [goodReport](#goodreport)
31
+ - [badReport](#badreport)
32
+ - [balance](#balance)
33
+ - [Proxies](#proxies)
34
+ - [Examples](#examples)
35
+ - [Useful articles](#useful-articles)
36
+
37
+
38
+ ## Installation
39
+ This package can be installed with NPM:
44
40
 
45
41
  ```sh
46
42
  npm install @2captcha/captcha-solver
47
43
  ```
48
- or
44
+ or Yarn:
49
45
  ```sh
50
46
  yarn add @2captcha/captcha-solver
51
47
  ```
52
48
 
53
49
  ## Configuration
54
50
 
55
- Instance can be created like this:
51
+ TwoCaptcha instance can be created like this:
56
52
 
57
53
  ```js
58
- const Captcha = require("@2captcha/captcha-solver")
59
- const solver = new Captcha.Solver("<Your 2captcha api key>")
54
+ const TwoCaptcha = require("@2captcha/captcha-solver")
55
+ const solver = new TwoCaptcha.Solver("<Your 2captcha api key>")
60
56
  ```
61
57
 
58
+ Also, there are a few options that can be configured:
59
+
60
+ ```javascript
61
+ const apiKey = 'YOUR_API_KEY'
62
+ const pollingInterval = 10
63
+
64
+ const solver = new TwoCaptcha.Solver(apiKey, pollingInterval)
65
+ ```
66
+ ### TwoCaptcha instance options
67
+
68
+ | Option | Default value | Description |
69
+ | ---------------- | -------------- | -------------------------------------------------------------------------------------------- |
70
+ | apiKey | - | Your API key |
71
+ | pollingInterval | 5000 | Interval in milliseconds between requests to the `res.php` API endpoint. Setting values less than 5 seconds is not recommended |
72
+
62
73
  ## Solve captcha
63
74
 
75
+ When you submit any image-based captcha use can provide additional options to help 2captcha workers to solve it properly.
76
+
77
+ ### Captcha options
78
+
79
+ | Option | Default Value | Description |
80
+ | ------------- | ------------- | -------------------------------------------------------------------------------------------------- |
81
+ | numeric | 0 | Defines if the captcha contains numeric or other symbols [see more info in the API docs][post options] |
82
+ | min_len | 0 | minimal answer length |
83
+ | max_len | 0 | maximum answer length |
84
+ | phrase | 0 | defines if the answer contains multiple words or not |
85
+ | regsense | 0 | defines if the answer is case sensitive |
86
+ | calc | 0 | defines captcha requires calculation |
87
+ | lang | - | defines the captcha language; see the [list of supported languages] |
88
+ | textinstructions| - | hint or task text shown to workers with the captcha |
89
+
90
+ Below you can find basic examples for every captcha type, check out the code below.
91
+
92
+ ### Image captcha
93
+
94
+ <sup>[API method description.](https://2captcha.com/2captcha-api#solving_normal_captcha)</sup>
95
+
96
+ 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.
97
+
98
+ ```js
99
+ // Read from a file as base64 text
100
+ const imageBase64 = fs.readFileSync("./examples/media/imageCaptcha_6e584.png", "base64")
101
+
102
+ solver.imageCaptcha({
103
+ body: imageBase64,
104
+ numeric: 4,
105
+ min_len: 5,
106
+ max_len: 5
107
+ })
108
+ .then((res) => {
109
+ // Logs the image text
110
+ console.log(res);
111
+ })
112
+ .catch((err) => {
113
+ console.log(err);
114
+ })
115
+ ```
116
+
64
117
  ### reCAPTCHA V2
65
118
 
66
- Use this method to solve reCAPTCHA V2 and obtain a token to bypass the protection.
119
+ <sup>[API method description.](https://2captcha.com/2captcha-api#solving_recaptchav2_new)</sup>
120
+
121
+ Use the following method to solve reCAPTCHA V2 and obtain a token to bypass the protection.
67
122
 
68
123
  ```js
69
124
  solver.recaptcha({
@@ -80,7 +135,9 @@ solver.recaptcha({
80
135
 
81
136
  ### reCAPTCHA V3
82
137
 
83
- This method provides reCAPTCHA V3 solver and returns a token.
138
+ <sup>[API method description.](https://2captcha.com/2captcha-api#solving_recaptchav3)</sup>
139
+
140
+ This method provides a reCAPTCHA V3 solver and returns a token.
84
141
 
85
142
  ```js
86
143
  solver.recaptcha({
@@ -101,7 +158,9 @@ solver.recaptcha({
101
158
 
102
159
  ### hCaptcha
103
160
 
104
- Use this method to solve hCaptcha challenge. Returns a token to bypass captcha.
161
+ <sup>[API method description.](https://2captcha.com/2captcha-api#solving_hcaptcha)</sup>
162
+
163
+ Use this method to solve the hCaptcha challenge. Returns a token to bypass the captcha.
105
164
 
106
165
  ```js
107
166
  solver.hcaptcha({
@@ -116,7 +175,9 @@ solver.hcaptcha({
116
175
  })
117
176
  ```
118
177
 
119
- ### Arkose Labs FunCaptcha
178
+ ### FunCaptcha
179
+
180
+ <sup>[API method description.](https://2captcha.com/2captcha-api#solving_funcaptcha_new)</sup>
120
181
 
121
182
  FunCaptcha (Arkoselabs) solving method. Returns a token.
122
183
 
@@ -133,32 +194,10 @@ solver.funCaptcha({
133
194
  })
134
195
  ```
135
196
 
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
197
  ### GeeTest Captcha
161
198
 
199
+ <sup>[API method description.](https://2captcha.com/2captcha-api#solving_geetest)</sup>
200
+
162
201
  Method to solve GeeTest puzzle captcha. Returns a set of tokens as JSON.
163
202
 
164
203
  ```js
@@ -178,7 +217,9 @@ solver.geetest({
178
217
 
179
218
  ### GeeTest V4 Captcha
180
219
 
181
- Method to solve GeeTest V4 puzzle captcha. Returns a set of tokens as JSON.
220
+ <sup>[API method description.](https://2captcha.com/2captcha-api#geetest-v4)</sup>
221
+
222
+ Use this method to solve GeeTest v4. Returns the response in JSON.
182
223
 
183
224
  ```js
184
225
  solver.geetestV4({
@@ -210,9 +251,11 @@ solver.yandexSmart({
210
251
  })
211
252
  ```
212
253
 
213
- ### Lemin captcha
254
+ ### Lemin Cropped Captcha
255
+
256
+ <sup>[API method description.](https://2captcha.com/2captcha-api#lemin)</sup>
214
257
 
215
- Use this method to solve Lemin captcha and obtain a token to bypass the protection.
258
+ Use this method to solve Lemin and obtain a token to bypass the protection.
216
259
 
217
260
  ```js
218
261
  solver.lemin({
@@ -231,7 +274,11 @@ solver.lemin({
231
274
 
232
275
  ### Cloudflare Turnstile
233
276
 
234
- Use this method to solve Turnstile and obtain a token to bypass the protection.
277
+ <sup>[API method description.](https://2captcha.com/2captcha-api#turnstile)</sup>
278
+
279
+ Use this method to solve Cloudflare Turnstile. Returns JSON with the token.
280
+
281
+ 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
282
 
236
283
  ```js
237
284
  solver.cloudflareTurnstile({
@@ -246,9 +293,11 @@ solver.cloudflareTurnstile({
246
293
  })
247
294
  ```
248
295
 
249
- <h3 id="amazon-waf-captcha">Amazon WAF Captcha (AWS WAF):</h3>
296
+ ### Amazon WAF
297
+
298
+ <sup>[API method description.](https://2captcha.com/2captcha-api#amazon-waf)</sup>
250
299
 
251
- Use this method to solve AmazonWaf and obtain a token to bypass the protection.
300
+ 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
301
 
253
302
  ```js
254
303
  //INFO: The `context` value is dynamic, it is necessary to take the actual value from the page each time.
@@ -266,7 +315,9 @@ solver.amazonWaf({
266
315
  })
267
316
  ```
268
317
 
269
- ### Capy Puzzle
318
+ ### Capy
319
+
320
+ <sup>[API method description.](https://2captcha.com/2captcha-api#solving_capy)</sup>
270
321
 
271
322
  Token-based method to bypass Capy puzzle captcha.
272
323
 
@@ -285,10 +336,12 @@ solver.capyPuzzle({
285
336
 
286
337
  ### DataDome CAPTCHA
287
338
 
339
+ <sup>[API method description.](https://2captcha.com/2captcha-api#datadome)</sup>
340
+
288
341
  Use this method to solve DataDome and obtain a token to bypass the protection.
289
342
 
290
343
  > [!IMPORTANT]
291
- > To solve the DataDome captcha, you must use a proxy. It is recommended to use mobile residential proxies.
344
+ > To solve the DataDome captcha, you must use a proxy. It is recommended to use [residential proxies][Buy residential proxies].
292
345
 
293
346
  ```js
294
347
  solver.dataDome({
@@ -308,6 +361,8 @@ console.log(err);
308
361
 
309
362
  ### CyberSiARA
310
363
 
364
+ <sup>[API method description.](https://2captcha.com/2captcha-api#cybersiara)</sup>
365
+
311
366
  Use this method to solve CyberSiARA and obtain a token to bypass the protection.
312
367
 
313
368
  ```js
@@ -326,6 +381,8 @@ console.log(err);
326
381
 
327
382
  ### MTCaptcha
328
383
 
384
+ <sup>[API method description.](https://2captcha.com/2captcha-api#mtcaptcha)</sup>
385
+
329
386
  Use this method to solve MTCaptcha and obtain a token to bypass the protection.
330
387
 
331
388
  ```js
@@ -343,8 +400,12 @@ console.log(err);
343
400
 
344
401
  ### Friendly Captcha
345
402
 
403
+ <sup>[API method description.](https://2captcha.com/2captcha-api#friendly-captcha)</sup>
404
+
346
405
  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.
406
+
407
+ > [!IMPORTANT]
408
+ > 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
409
 
349
410
  ```js
350
411
  solver.friendlyCaptcha({
@@ -359,9 +420,11 @@ console.log(err);
359
420
  })
360
421
  ```
361
422
 
362
- <h3 id="coordinates-captcha">Coordinates (Click Captcha):</h3>
423
+ ### ClickCaptcha
424
+
425
+ <sup>[API method description.](https://2captcha.com/2captcha-api#coordinates)</sup>
363
426
 
364
- ClickCaptcha method returns coordinates of points on captcha image. Can be used if you need to click on particular points on the image.
427
+ 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
428
 
366
429
  ```js
367
430
  const imageBase64 = fs.readFileSync("./tests/media/hCaptchaImage.jpg", "base64")
@@ -378,9 +441,14 @@ solver.coordinates({
378
441
  })
379
442
  ```
380
443
 
381
- ### Bounding Box Method:
444
+ ### Bounding Box Method
445
+
446
+ <sup>[API method description.](https://2captcha.com/2captcha-api#bounding_box)</sup>
382
447
 
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`.
448
+
449
+ 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.
450
+ > [!IMPORTANT]
451
+ > You must to send instruction `imginstructions` or `textinstructions`.
384
452
 
385
453
  ```js
386
454
  solver.boundingBox({
@@ -395,22 +463,25 @@ solver.boundingBox({
395
463
  })
396
464
  ```
397
465
 
398
- ### Usage of proxy
466
+ ### Grid
399
467
 
400
- Solving reCAPTCHA V2 whis a proxy, code example:
468
+ <sup>[API method description.](https://2captcha.com/2captcha-api#grid)</sup>
469
+
470
+ 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.
471
+
472
+ > [!IMPORTANT]
473
+ > You must to send instruction `imginstructions` or `textinstructions`.
401
474
 
402
475
  ```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.
476
+ solver.grid({
477
+ body: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAR4AAACwCAIAAAB...",
478
+ textinstructions: "Select cars in the image"
408
479
  })
409
480
  .then((res) => {
410
- console.log(res)
481
+ console.log(res);
411
482
  })
412
483
  .catch((err) => {
413
- console.error(err.message)
484
+ console.log(err);
414
485
  })
415
486
  ```
416
487
 
@@ -418,6 +489,8 @@ solver.recaptcha({
418
489
 
419
490
  ### goodReport
420
491
 
492
+ <sup>[API method description.](https://2captcha.com/2captcha-api#reporting-answers)</sup>
493
+
421
494
  Use this method to report good captcha answer.
422
495
 
423
496
  ```js
@@ -426,6 +499,8 @@ solver.goodReport('7031846604')
426
499
 
427
500
  ### badReport
428
501
 
502
+ <sup>[API method description.](https://2captcha.com/2captcha-api#reporting-answers)</sup>
503
+
429
504
  Use this method to report bad captcha answer.
430
505
 
431
506
  ```js
@@ -434,7 +509,9 @@ solver.badReport('7031854546')
434
509
 
435
510
  ### balance
436
511
 
437
- Use this method to get your account's balance
512
+ <sup>[API method description.](https://2captcha.com/2captcha-api#additional-methods)</sup>
513
+
514
+ Use this method to get your account's balance.
438
515
 
439
516
  ```js
440
517
  solver.balance()
@@ -458,13 +535,21 @@ solver.recaptcha({
458
535
  proxytype: 'login:password@123.123.123.123:3128'
459
536
  })
460
537
  ```
538
+ ## Examples
461
539
 
540
+ Examples of solving all supported captcha types are located in the [examples] directory.
462
541
 
463
542
  ## Useful articles
543
+ * [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)
544
+ * [Bypassing Cloudflare Challenge with Puppeteer and 2Captcha](https://2captcha.com/blog/bypassing-cloudflare-challenge-with-puppeteer-and-2captcha)
464
545
  * [How to bypass Geetest v4 CAPTCHA](https://2captcha.com/blog/geetest-v4-support)
465
546
  * [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>
547
+ * [Custom Slider Captcha Demo](https://github.com/2captcha/custom-slider-demo)
548
+ * [Cloudflare Challenge page bypass code example](https://github.com/2captcha/cloudflare-demo)
467
549
 
468
550
  <!-- Shared links -->
551
+ [post options]: https://2captcha.com/2captcha-api#normal_post
552
+ [list of supported languages]: https://2captcha.com/2captcha-api#language
469
553
  [Buy residential proxies]: https://2captcha.com/proxy/residential-proxies
470
- [Quick start]: https://2captcha.com/proxy?openAddTrafficModal=true
554
+ [Quick start]: https://2captcha.com/proxy?openAddTrafficModal=true
555
+ [examples]: ./examples
@@ -120,6 +120,8 @@ export interface paramsAmazonWAF {
120
120
  sitekey: string;
121
121
  iv: string;
122
122
  context: string;
123
+ challenge_script?: string;
124
+ captcha_script?: string;
123
125
  header_acao?: boolean;
124
126
  pingback?: string;
125
127
  soft_id?: number;
@@ -190,6 +192,20 @@ export interface paramsBoundingBox {
190
192
  textinstructions?: string;
191
193
  imginstructions?: string;
192
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
+ }
193
209
  /**
194
210
  * An object containing properties of the captcha solution.
195
211
  * @typedef {Object} CaptchaAnswer
@@ -286,7 +302,7 @@ export declare class Solver {
286
302
  */
287
303
  recaptcha(params: paramsRecaptcha): Promise<CaptchaAnswer>;
288
304
  /**
289
- * Solves a hCaptcha, returning the result as a string.
305
+ * ### Solves a hCaptcha
290
306
  *
291
307
  * [Read more about other hCaptcha parameters](https://2captcha.com/2captcha-api#solving_hcaptcha).
292
308
  *
@@ -316,7 +332,9 @@ export declare class Solver {
316
332
  */
317
333
  hcaptcha(params: paramsHCaptcha): Promise<CaptchaAnswer>;
318
334
  /**
319
- * Solves a GeeTest Captcha. [Read more about parameters and solving for Geetest captcha](https://2captcha.com/2captcha-api#solving_geetest).
335
+ * ### Solves a GeeTest Captcha.
336
+ *
337
+ * [Read more about parameters and solving for Geetest captcha](https://2captcha.com/2captcha-api#solving_geetest).
320
338
  *
321
339
  * @param {{ gt, challenge, api_server, offline, new_captcha,
322
340
  * pageurl, pingback, proxy, proxytype, userAgent }} params
@@ -369,7 +387,6 @@ export declare class Solver {
369
387
  /**
370
388
  * ### Solves a GeeTest V4 Captcha.
371
389
  *
372
- *
373
390
  * This method accepts an object with the following fields: `pageurl`, `captcha_id`, `pingback`, `proxy`, `proxytype`, `userAgent`.
374
391
  * The `pageurl` and `captcha_id` fields are required.
375
392
  *
@@ -397,7 +414,8 @@ export declare class Solver {
397
414
  */
398
415
  geetestV4(params: paramsGeeTestV4): Promise<CaptchaAnswer>;
399
416
  /**
400
- * Method for sending Yandex Smart Captcha.
417
+ * ### Method for sending Yandex Smart Captcha.
418
+ *
401
419
  * This method accepts an object with the following fields: `pageurl`, `sitekey`, `pingback`, `proxy`, `proxytype`.
402
420
  * The `pageurl` and `sitekey` fields are required.
403
421
  *
@@ -425,7 +443,9 @@ export declare class Solver {
425
443
  */
426
444
  yandexSmart(params: yandexSmart): Promise<CaptchaAnswer>;
427
445
  /**
428
- * Solves a image-based captcha. [Read more about parameters for image captcha](https://2captcha.com/2captcha-api#solving_normal_captcha).
446
+ * ### Solves a image-based captcha.
447
+ *
448
+ * [Read more about parameters for image captcha](https://2captcha.com/2captcha-api#solving_normal_captcha).
429
449
  *
430
450
  * @param {{ body,
431
451
  * phrase,
@@ -536,11 +556,13 @@ export declare class Solver {
536
556
  *
537
557
  * [Read more about "Amazon WAF" captcha](https://2captcha.com/2captcha-api#amazon-waf).
538
558
  *
539
- * @param {{ pageurl, sitekey, iv, context, pingback, proxy, proxytype}} params The `amazonWaf` method takes arguments as an object. Thus, the `pageurl`, `sitekey`, `iv`, `context` fields in the passed object are mandatory.
559
+ * @param {{ pageurl, sitekey, iv, context, challenge_script, captcha_script, pingback, proxy, proxytype}} params The `amazonWaf` method takes arguments as an object. Thus, the `pageurl`, `sitekey`, `iv`, `context` fields in the passed object are mandatory.
540
560
  * @param {string} params.pageurl Is the full `URL` of page where you were challenged by the captcha.
541
561
  * @param {string} params.sitekey Is a value of `key` parameter in the page source.
542
562
  * @param {string} params.iv Is a value of `iv` parameter in the page source.
543
563
  * @param {string} params.context Is a value of `context` parameter in the page source.
564
+ * @param {string} params.challenge_script The source URL of `challenge.js` script on the page.
565
+ * @param {string} params.captcha_script The source URL of `captcha.js` script on the page.
544
566
  * @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).
545
567
  * @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).
546
568
  * @param {string} params.proxytype Type of your proxy: `HTTP`, `HTTPS`, `SOCKS4`, `SOCKS5`.
@@ -616,16 +638,6 @@ export declare class Solver {
616
638
  * })
617
639
  */
618
640
  coordinates(params: paramsCoordinates): Promise<CaptchaAnswer>;
619
- /**
620
- * pageurl: string,
621
- captchakey: string,
622
- api_server?: string,
623
- version?: string,
624
- header_acao?: boolean,
625
- pingback?: string,
626
- proxy?: string,
627
- proxytype?: string,
628
- */
629
641
  /**
630
642
  * ### Solves Capy Puzzle captcha
631
643
  *
@@ -793,6 +805,38 @@ export declare class Solver {
793
805
  * })
794
806
  */
795
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>;
796
840
  /**
797
841
  * Reports a captcha as correctly solved.
798
842
  *
@@ -1 +1 @@
1
- {"version":3,"file":"2captcha.d.ts","sourceRoot":"","sources":["../../src/structs/2captcha.ts"],"names":[],"mappings":"AAUA,MAAM,WAAW,eAAe;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACj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;;;;;;;;;;;;OAuBG;IACU,UAAU,CAAC,MAAM,EAAE,gBAAgB,GAAG,OAAO,CAAC,aAAa,CAAC;IA0BzE;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;IACU,QAAQ,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAAC,aAAa,CAAC;IA0BzE;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IACU,UAAU,CAAC,MAAM,EAAE,gBAAgB,GAAG,OAAO,CAAC,aAAa,CAAC;IA0BzE;;;;;;;;;;;;;;;;;;;;;OAqBG;IACU,SAAS,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,aAAa,CAAC;IA0BvE;;;;;;;;;;;;;;;;;;;;;OAqBG;IACU,UAAU,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,aAAa,CAAC;IA0BxE;;;;;;;;;;;;;;;;;;;;;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"}
@@ -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.
@@ -184,7 +185,7 @@ class Solver {
184
185
  }
185
186
  }
186
187
  /**
187
- * Solves a hCaptcha, returning the result as a string.
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. [Read more about parameters and solving for Geetest captcha](https://2captcha.com/2captcha-api#solving_geetest).
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. [Read more about parameters for image captcha](https://2captcha.com/2captcha-api#solving_normal_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,
@@ -593,11 +598,13 @@ class Solver {
593
598
  *
594
599
  * [Read more about "Amazon WAF" captcha](https://2captcha.com/2captcha-api#amazon-waf).
595
600
  *
596
- * @param {{ pageurl, sitekey, iv, context, pingback, proxy, proxytype}} params The `amazonWaf` method takes arguments as an object. Thus, the `pageurl`, `sitekey`, `iv`, `context` fields in the passed object are mandatory.
601
+ * @param {{ pageurl, sitekey, iv, context, challenge_script, captcha_script, pingback, proxy, proxytype}} params The `amazonWaf` method takes arguments as an object. Thus, the `pageurl`, `sitekey`, `iv`, `context` fields in the passed object are mandatory.
597
602
  * @param {string} params.pageurl Is the full `URL` of page where you were challenged by the captcha.
598
603
  * @param {string} params.sitekey Is a value of `key` parameter in the page source.
599
604
  * @param {string} params.iv Is a value of `iv` parameter in the page source.
600
605
  * @param {string} params.context Is a value of `context` parameter in the page source.
606
+ * @param {string} params.challenge_script The source URL of `challenge.js` script on the page.
607
+ * @param {string} params.captcha_script The source URL of `captcha.js` script on the page.
601
608
  * @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).
602
609
  * @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).
603
610
  * @param {string} params.proxytype Type of your proxy: `HTTP`, `HTTPS`, `SOCKS4`, `SOCKS5`.
@@ -745,16 +752,6 @@ class Solver {
745
752
  throw new _2captchaError_1.APIError(data.request);
746
753
  }
747
754
  }
748
- /**
749
- * pageurl: string,
750
- captchakey: string,
751
- api_server?: string,
752
- version?: string,
753
- header_acao?: boolean,
754
- pingback?: string,
755
- proxy?: string,
756
- proxytype?: string,
757
- */
758
755
  /**
759
756
  * ### Solves Capy Puzzle captcha
760
757
  *
@@ -1081,6 +1078,67 @@ class Solver {
1081
1078
  throw new _2captchaError_1.APIError(data.request);
1082
1079
  }
1083
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
+ }
1084
1142
  /**
1085
1143
  * Reports a captcha as correctly solved.
1086
1144
  *
@@ -1 +1 @@
1
- {"version":3,"file":"checkCaptchaParams.d.ts","sourceRoot":"","sources":["../../src/utils/checkCaptchaParams.ts"],"names":[],"mappings":"AAqFA;;;;;GAKG;AACH,MAAM,CAAC,OAAO,UAAU,kBAAkB,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,uBAgCxE"}
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.0.3",
3
+ "version": "1.1.0",
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": {
@@ -44,11 +44,10 @@
44
44
  "Friendly Captcha"
45
45
  ],
46
46
  "scripts": {
47
- "go": "tsc && node ./dist/index.js",
48
- "dev": "tsc && node ./issues/dev",
47
+ "build": "tsc && node ./dist/index.js",
49
48
  "jsdoc": "jsdoc",
50
49
  "docgen": "tsc && yarn jsdoc ./dist -R \"./readme.md\" -P \"./package.json\" -t \"./node_modules/jaguarjs-jsdoc\" -d \"./docs\" -r",
51
- "test": "tsc && node ./tests/mtCaptcha.js"
50
+ "example": "tsc && node ./tests/mtCaptcha.js"
52
51
  },
53
52
  "dependencies": {
54
53
  "node-fetch": "^2.6.1"
package/tsconfig.json CHANGED
@@ -64,7 +64,7 @@
64
64
  "forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */
65
65
  },
66
66
  "exclude": [
67
- "tests/*",
67
+ "examples/*",
68
68
  "dist/*"
69
69
  ]
70
70
  }