Skip to content

Commit a18c927

Browse files
committed
fix altcha
1 parent 7ba1f03 commit a18c927

4 files changed

Lines changed: 6 additions & 21 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -748,6 +748,7 @@ This method can be used to solve Altcha captcha. Returns a token.
748748
solver.altcha({
749749
pageurl: "https://mysite.com/page/with/altcha",
750750
challenge_url: "https://example/altcha",
751+
challenge_json: '{"algorithm":"SHA-256","challenge":"a4c9d8e7f1b23a6c...",..."signature":"7b3e2a9d5c8f1046e2d91c3a..."}'
751752
})
752753
.then((res) => {
753754
console.log(res);

examples/altcha.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ const solver = new TwoCaptcha.Solver(APIKEY);
66
solver.altcha({
77
pageurl: "https://mysite.com/page/with/altcha",
88
challenge_url: "https://example/altcha",
9-
// challenge_json: '{"algorithm":"SHA-256","challenge":"a4c9d8e7f1b23a6c...",..."signature":"7b3e2a9d5c8f1046e2d91c3a..."}'
9+
challenge_json: '{"algorithm":"SHA-256","challenge":"a4c9d8e7f1b23a6c...",..."signature":"7b3e2a9d5c8f1046e2d91c3a..."}'
1010
})
1111
.then((res) => {
1212
console.log(res);
1313
})
1414
.catch((err) => {
1515
console.log(err);
16-
})
16+
})

src/structs/2captcha.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2160,15 +2160,16 @@ public async temu(params: paramsTemu): Promise<CaptchaAnswer> {
21602160
*
21612161
* @param {{ pageurl, challenge_url, challenge_json, proxy, proxytype}} params Parameters Altcha as an object.
21622162
* @param {string} params.pageurl Full URL of the page where you solve the captcha.
2163-
* @param {string} params.challenge_url The value of the 'challenge_url' parameter for the 'altcha-widget' element containing the captcha on the page. You can send either challenge_url or challenge_json parameter, but not two of it simultaneously.
2164-
* @param {string} params.challenge_json The contents of the file from the 'challenge_url' parameter. You can send either challenge_url or challenge_json parameter, but not two of it simultaneously.
2163+
* @param {string} params.challenge_url The value of the 'challenge_url' parameter for the 'altcha-widget' element containing the captcha on the page.
2164+
* @param {string} params.challenge_json The contents of the file from the 'challenge_url' parameter.
21652165
* @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).
21662166
* @param {string} params.proxytype Type of your proxy: `HTTP`, `HTTPS`, `SOCKS4`, `SOCKS5`.
21672167
*
21682168
* @example
21692169
* solver.altcha({
21702170
* pageurl: "https://mysite.com/page/with/altcha",
21712171
* challenge_url: "https://example/altcha",
2172+
* challenge_json: '{"algorithm":"SHA-256","challenge":"a4c9d8e7f1b23a6c...",..."signature":"7b3e2a9d5c8f1046e2d91c3a..."}'
21722173
* })
21732174
* .then((res) => {
21742175
* console.log(res);

src/utils/checkCaptchaParams.ts

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -180,23 +180,6 @@ export default function checkCaptchaParams(params: Object, method: string) {
180180
}
181181
})
182182

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-
200183
//The parameters `textinstructions` and `imginstructions` are mandatory for the methods `bounding_box`, `grid`, and `canvas`.
201184
if(method === "bounding_box" || method === "grid" || method === "canvas") {
202185
if(params.hasOwnProperty('textinstructions') || params.hasOwnProperty('imginstructions')) {

0 commit comments

Comments
 (0)