@2captcha/captcha-solver 1.1.1 → 1.3.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 +192 -8
- package/dist/structs/2captcha.d.ts +287 -45
- package/dist/structs/2captcha.d.ts.map +1 -1
- package/dist/structs/2captcha.js +436 -22
- package/dist/utils/checkCaptchaParams.d.ts +8 -0
- package/dist/utils/checkCaptchaParams.d.ts.map +1 -1
- package/dist/utils/checkCaptchaParams.js +49 -16
- package/dist/utils/renameParams.d.ts.map +1 -1
- package/dist/utils/renameParams.js +15 -1
- package/package.json +1 -1
|
@@ -2,7 +2,8 @@
|
|
|
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', 'grid'
|
|
5
|
+
"turnstile", "base64", "capy", "datadome", "cybersiara", "mt_captcha", "bounding_box", 'friendly_captcha', 'grid',
|
|
6
|
+
'textcaptcha', 'canvas', 'rotatecaptcha', 'keycaptcha', 'cutcaptcha', 'tencent', 'atb_captcha', 'audio'];
|
|
6
7
|
// Names of required fields that must be contained in the parameters captcha
|
|
7
8
|
const recaptchaRequiredFields = ['pageurl', 'googlekey'];
|
|
8
9
|
const hcaptchaRequiredFields = ['pageurl', 'sitekey'];
|
|
@@ -17,11 +18,19 @@ const turnstileRequiredFields = ['pageurl', 'sitekey'];
|
|
|
17
18
|
const base64RequiredFields = ['body'];
|
|
18
19
|
const capyPuzzleRequiredFields = ['captchakey'];
|
|
19
20
|
const dataDomeRequiredFields = ['pageurl', 'captcha_url', 'userAgent', 'proxy', 'proxytype'];
|
|
20
|
-
const
|
|
21
|
-
const
|
|
21
|
+
const cyberSiARARequiredFields = ['pageurl', 'master_url_id', 'userAgent'];
|
|
22
|
+
const mtCaptchaRequiredFields = ['pageurl', 'sitekey'];
|
|
22
23
|
const boundingBoxRequiredFields = ['image']; // and textinstructions or imginstructions
|
|
23
24
|
const friendlyCaptchaFields = ['pageurl', 'sitekey'];
|
|
24
25
|
const gridRequiredFields = ['body']; // and textinstructions or imginstructions
|
|
26
|
+
const textCaptchaRequiredFields = ['textcaptcha'];
|
|
27
|
+
const canvasRequiredFields = ['body']; // and textinstructions or imginstructions
|
|
28
|
+
const rotateRequiredFields = ['body'];
|
|
29
|
+
const keycaptchaRequiredFields = ['pageurl', 's_s_c_user_id', 's_s_c_session_id', 's_s_c_web_server_sign', 's_s_c_web_server_sign2'];
|
|
30
|
+
const cutcaptchaRequiredFields = ['pageurl', 'misery_key', 'api_key'];
|
|
31
|
+
const tencentRequiredFields = ['pageurl', 'app_id'];
|
|
32
|
+
const atbCaptchaRequiredFields = ['pageurl', 'app_id', 'api_server'];
|
|
33
|
+
const audioRequiredFields = ['body', 'lang'];
|
|
25
34
|
/**
|
|
26
35
|
* Getting required arguments for a captcha.
|
|
27
36
|
*
|
|
@@ -71,10 +80,10 @@ const getRequiredFildsArr = (method) => {
|
|
|
71
80
|
requiredFieldsArr = dataDomeRequiredFields;
|
|
72
81
|
break;
|
|
73
82
|
case "cybersiara":
|
|
74
|
-
requiredFieldsArr =
|
|
83
|
+
requiredFieldsArr = cyberSiARARequiredFields;
|
|
75
84
|
break;
|
|
76
85
|
case "mt_captcha":
|
|
77
|
-
requiredFieldsArr =
|
|
86
|
+
requiredFieldsArr = mtCaptchaRequiredFields;
|
|
78
87
|
break;
|
|
79
88
|
case "bounding_box":
|
|
80
89
|
requiredFieldsArr = boundingBoxRequiredFields;
|
|
@@ -82,10 +91,42 @@ const getRequiredFildsArr = (method) => {
|
|
|
82
91
|
case "friendly_captcha":
|
|
83
92
|
requiredFieldsArr = friendlyCaptchaFields;
|
|
84
93
|
break;
|
|
94
|
+
case "textcaptcha":
|
|
95
|
+
requiredFieldsArr = textCaptchaRequiredFields;
|
|
96
|
+
break;
|
|
97
|
+
case "canvas":
|
|
98
|
+
requiredFieldsArr = canvasRequiredFields;
|
|
99
|
+
break;
|
|
100
|
+
case "rotatecaptcha":
|
|
101
|
+
requiredFieldsArr = rotateRequiredFields;
|
|
102
|
+
break;
|
|
103
|
+
case "keycaptcha":
|
|
104
|
+
requiredFieldsArr = keycaptchaRequiredFields;
|
|
105
|
+
break;
|
|
106
|
+
case "cutcaptcha":
|
|
107
|
+
requiredFieldsArr = cutcaptchaRequiredFields;
|
|
108
|
+
break;
|
|
109
|
+
case "tencent":
|
|
110
|
+
requiredFieldsArr = tencentRequiredFields;
|
|
111
|
+
break;
|
|
112
|
+
case "atb_captcha":
|
|
113
|
+
requiredFieldsArr = atbCaptchaRequiredFields;
|
|
114
|
+
break;
|
|
115
|
+
case "audio":
|
|
116
|
+
requiredFieldsArr = audioRequiredFields;
|
|
117
|
+
break;
|
|
85
118
|
}
|
|
86
119
|
return requiredFieldsArr;
|
|
87
120
|
};
|
|
88
121
|
/**
|
|
122
|
+
* ### Captcha Required Parameters Check.
|
|
123
|
+
*
|
|
124
|
+
* Checking required captcha parameters before sending.
|
|
125
|
+
* This function checks for required fields in the provided captcha parameters.
|
|
126
|
+
* Throws an error if the specified method is not supported or if required fields are missing.
|
|
127
|
+
*
|
|
128
|
+
* Note: The `checkCaptchaParams()` function should be called after `renameParams()`, if function `renameParams()` is used.
|
|
129
|
+
*
|
|
89
130
|
* @param { Object } params Captcha parameters that need to be checked.
|
|
90
131
|
* @returns true | false | Error
|
|
91
132
|
* @example
|
|
@@ -109,22 +150,14 @@ function checkCaptchaParams(params, method) {
|
|
|
109
150
|
isCorrectCaptchaParams = true;
|
|
110
151
|
}
|
|
111
152
|
});
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
isCorrectCaptchaParams = true;
|
|
115
|
-
}
|
|
116
|
-
else {
|
|
117
|
-
isCorrectCaptchaParams = false;
|
|
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") {
|
|
153
|
+
//The parameters `textinstructions` and `imginstructions` are mandatory for the methods `bounding_box`, `grid`, and `canvas`.
|
|
154
|
+
if (method === "bounding_box" || method === "grid" || method === "canvas") {
|
|
122
155
|
if (params.hasOwnProperty('textinstructions') || params.hasOwnProperty('imginstructions')) {
|
|
123
156
|
isCorrectCaptchaParams = true;
|
|
124
157
|
}
|
|
125
158
|
else {
|
|
126
159
|
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 "
|
|
160
|
+
throw new Error(`Error when check params captcha.\nNot found "textinstructions" or "imginstructions" field in the Object. One of this field is required for "${method}" method. Please add field "textinstructions" or "imginstructions" to captcha parameters.`);
|
|
128
161
|
}
|
|
129
162
|
}
|
|
130
163
|
return isCorrectCaptchaParams;
|
|
@@ -1 +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,
|
|
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,OA0C/C"}
|
|
@@ -16,12 +16,26 @@ function renameParams(params) {
|
|
|
16
16
|
* Captcha parameters that need to be renamed before sent to the API.
|
|
17
17
|
*/
|
|
18
18
|
const replaceParams = {
|
|
19
|
+
// Grid
|
|
19
20
|
"cols": "recaptchacols",
|
|
20
21
|
"rows": "recaptcharows",
|
|
21
22
|
"minClicks": "min_clicks",
|
|
22
23
|
"maxClicks": "max_clicks",
|
|
23
24
|
"canSkip": "can_no_answer",
|
|
24
|
-
"previousId": "previousID"
|
|
25
|
+
"previousId": "previousID",
|
|
26
|
+
"imgType": "img_type",
|
|
27
|
+
// KeyCaptcha
|
|
28
|
+
"userId": "s_s_c_user_id",
|
|
29
|
+
"sessionId": "s_s_c_session_id",
|
|
30
|
+
"webServerSign": "s_s_c_web_server_sign",
|
|
31
|
+
"webServerSign2": "s_s_c_web_server_sign2",
|
|
32
|
+
// Cutcaptcha
|
|
33
|
+
"miseryKey": "misery_key",
|
|
34
|
+
"apiKey": "api_key",
|
|
35
|
+
// Tencent
|
|
36
|
+
"appId": "app_id",
|
|
37
|
+
// atbCAPTCHA
|
|
38
|
+
"apiServer": "api_server",
|
|
25
39
|
};
|
|
26
40
|
for (let key in params) {
|
|
27
41
|
if (replaceParams.hasOwnProperty(key)) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@2captcha/captcha-solver",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.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": {
|