@2captcha/captcha-solver 1.0.4 → 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 +24 -1
- package/dist/structs/2captcha.d.ts +55 -15
- package/dist/structs/2captcha.d.ts.map +1 -1
- package/dist/structs/2captcha.js +71 -15
- 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
|
@@ -25,6 +25,7 @@ The easiest way to quickly integrate the [2Captcha](https://2captcha.com/) captc
|
|
|
25
25
|
- [MTCaptcha](#mtcaptcha)
|
|
26
26
|
- [Friendly Captcha](#friendly-captcha)
|
|
27
27
|
- [Bounding Box Method](#bounding-box-method)
|
|
28
|
+
- [Grid](#grid)
|
|
28
29
|
- [Other methods](#other-methods)
|
|
29
30
|
- [goodReport](#goodreport)
|
|
30
31
|
- [badReport](#badreport)
|
|
@@ -440,7 +441,7 @@ solver.coordinates({
|
|
|
440
441
|
})
|
|
441
442
|
```
|
|
442
443
|
|
|
443
|
-
### Bounding Box Method
|
|
444
|
+
### Bounding Box Method
|
|
444
445
|
|
|
445
446
|
<sup>[API method description.](https://2captcha.com/2captcha-api#bounding_box)</sup>
|
|
446
447
|
|
|
@@ -462,6 +463,28 @@ solver.boundingBox({
|
|
|
462
463
|
})
|
|
463
464
|
```
|
|
464
465
|
|
|
466
|
+
### Grid
|
|
467
|
+
|
|
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`.
|
|
474
|
+
|
|
475
|
+
```js
|
|
476
|
+
solver.grid({
|
|
477
|
+
body: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAR4AAACwCAIAAAB...",
|
|
478
|
+
textinstructions: "Select cars in the image"
|
|
479
|
+
})
|
|
480
|
+
.then((res) => {
|
|
481
|
+
console.log(res);
|
|
482
|
+
})
|
|
483
|
+
.catch((err) => {
|
|
484
|
+
console.log(err);
|
|
485
|
+
})
|
|
486
|
+
```
|
|
487
|
+
|
|
465
488
|
## Other methods
|
|
466
489
|
|
|
467
490
|
### goodReport
|
|
@@ -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
|
|
@@ -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,
|
|
@@ -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
|
*
|
|
@@ -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/structs/2captcha.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"2captcha.d.ts","sourceRoot":"","sources":["../../src/structs/2captcha.ts"],"names":[],"mappings":"AAWA,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,CAA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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.
|
|
@@ -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,
|
|
@@ -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
|
*
|
|
@@ -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.0
|
|
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": {
|