|
1 | 1 | // Captcha methods for which parameter checking is available |
2 | 2 | const supportedMethods = ["userrecaptcha", "hcaptcha", "geetest", "geetest_v4","yandex","funcaptcha","lemin","amazon_waf", |
3 | 3 | "turnstile", "base64", "capy","datadome", "cybersiara", "mt_captcha", "bounding_box", 'friendly_captcha', 'grid', |
4 | | - 'textcaptcha', 'canvas', 'rotatecaptcha', 'keycaptcha', 'cutcaptcha', 'tencent', 'atb_captcha', 'prosopo', 'captchafox', 'vkimage', 'vkcaptcha', 'temu', 'audio'] |
| 4 | + 'textcaptcha', 'canvas', 'rotatecaptcha', 'keycaptcha', 'cutcaptcha', 'tencent', 'atb_captcha', 'prosopo', 'captchafox', 'vkimage', 'vkcaptcha', 'temu', 'altcha', 'audio'] |
5 | 5 |
|
6 | 6 | // Names of required fields that must be contained in the parameters captcha |
7 | 7 | const recaptchaRequiredFields = ['pageurl','googlekey'] |
@@ -34,6 +34,7 @@ const captchaFoxRequiredFields = ['pageurl', 'sitekey', 'userAgent', 'proxy', ' |
34 | 34 | const vkimageRequiredFields = ['body', 'steps'] |
35 | 35 | const vkcaptchaRequiredFields = ['redirect_uri', 'userAgent', 'proxy', 'proxytype'] |
36 | 36 | const temuRequiredFields = ['body', 'part1', 'part2', 'part3'] |
| 37 | +const altchaRequiredFields = ['pageurl'] |
37 | 38 | const audioRequiredFields = ['body', 'lang'] |
38 | 39 |
|
39 | 40 | /** |
@@ -133,6 +134,9 @@ const getRequiredFildsArr = (method: string):Array<string> => { |
133 | 134 | case "temu": |
134 | 135 | requiredFieldsArr = temuRequiredFields |
135 | 136 | break; |
| 137 | + case "altcha": |
| 138 | + requiredFieldsArr = altchaRequiredFields |
| 139 | + break; |
136 | 140 | case "audio": |
137 | 141 | requiredFieldsArr = audioRequiredFields |
138 | 142 | break; |
@@ -176,6 +180,23 @@ export default function checkCaptchaParams(params: Object, method: string) { |
176 | 180 | } |
177 | 181 | }) |
178 | 182 |
|
| 183 | + if(method === "altcha") { |
| 184 | + const hasChallengeUrl = params.hasOwnProperty('challenge_url') |
| 185 | + const hasChallengeJson = params.hasOwnProperty('challenge_json') |
| 186 | + |
| 187 | + if(!hasChallengeUrl && !hasChallengeJson) { |
| 188 | + isCorrectCaptchaParams = false |
| 189 | + throw new Error(`Error when check params captcha.\nNot found "challenge_url" or "challenge_json" field in the Object. One of this field is required for "${method}" method. Please add field "challenge_url" or "challenge_json" to captcha parameters.`) |
| 190 | + } |
| 191 | + |
| 192 | + if(hasChallengeUrl && hasChallengeJson) { |
| 193 | + isCorrectCaptchaParams = false |
| 194 | + throw new Error(`Error when check params captcha.\nYou must provide exactly one of "challenge_url" or "challenge_json" for "${method}" method.`) |
| 195 | + } |
| 196 | + |
| 197 | + isCorrectCaptchaParams = true |
| 198 | + } |
| 199 | + |
179 | 200 | //The parameters `textinstructions` and `imginstructions` are mandatory for the methods `bounding_box`, `grid`, and `canvas`. |
180 | 201 | if(method === "bounding_box" || method === "grid" || method === "canvas") { |
181 | 202 | if(params.hasOwnProperty('textinstructions') || params.hasOwnProperty('imginstructions')) { |
|
0 commit comments