Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -748,6 +748,7 @@ This method can be used to solve Altcha captcha. Returns a token.
solver.altcha({
pageurl: "https://mysite.com/page/with/altcha",
challenge_url: "https://example/altcha",
challenge_json: '{"algorithm":"SHA-256","challenge":"a4c9d8e7f1b23a6c...",..."signature":"7b3e2a9d5c8f1046e2d91c3a..."}'
})
.then((res) => {
console.log(res);
Expand Down
4 changes: 2 additions & 2 deletions examples/altcha.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ const solver = new TwoCaptcha.Solver(APIKEY);
solver.altcha({
pageurl: "https://mysite.com/page/with/altcha",
challenge_url: "https://example/altcha",
// challenge_json: '{"algorithm":"SHA-256","challenge":"a4c9d8e7f1b23a6c...",..."signature":"7b3e2a9d5c8f1046e2d91c3a..."}'
challenge_json: '{"algorithm":"SHA-256","challenge":"a4c9d8e7f1b23a6c...",..."signature":"7b3e2a9d5c8f1046e2d91c3a..."}'
})
.then((res) => {
console.log(res);
})
.catch((err) => {
console.log(err);
})
})
5 changes: 3 additions & 2 deletions src/structs/2captcha.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2160,15 +2160,16 @@ public async temu(params: paramsTemu): Promise<CaptchaAnswer> {
*
* @param {{ pageurl, challenge_url, challenge_json, proxy, proxytype}} params Parameters Altcha as an object.
* @param {string} params.pageurl Full URL of the page where you solve the captcha.
* @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.
* @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.
* @param {string} params.challenge_url The value of the 'challenge_url' parameter for the 'altcha-widget' element containing the captcha on the page.
* @param {string} params.challenge_json The contents of the file from the 'challenge_url' parameter.
* @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).
* @param {string} params.proxytype Type of your proxy: `HTTP`, `HTTPS`, `SOCKS4`, `SOCKS5`.
*
* @example
* solver.altcha({
* pageurl: "https://mysite.com/page/with/altcha",
* challenge_url: "https://example/altcha",
* challenge_json: '{"algorithm":"SHA-256","challenge":"a4c9d8e7f1b23a6c...",..."signature":"7b3e2a9d5c8f1046e2d91c3a..."}'
* })
* .then((res) => {
* console.log(res);
Expand Down
17 changes: 0 additions & 17 deletions src/utils/checkCaptchaParams.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,23 +180,6 @@ export default function checkCaptchaParams(params: Object, method: string) {
}
})

if(method === "altcha") {
const hasChallengeUrl = params.hasOwnProperty('challenge_url')
const hasChallengeJson = params.hasOwnProperty('challenge_json')

if(!hasChallengeUrl && !hasChallengeJson) {
isCorrectCaptchaParams = false
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.`)
}

if(hasChallengeUrl && hasChallengeJson) {
isCorrectCaptchaParams = false
throw new Error(`Error when check params captcha.\nYou must provide exactly one of "challenge_url" or "challenge_json" for "${method}" method.`)
}

isCorrectCaptchaParams = true
}

//The parameters `textinstructions` and `imginstructions` are mandatory for the methods `bounding_box`, `grid`, and `canvas`.
if(method === "bounding_box" || method === "grid" || method === "canvas") {
if(params.hasOwnProperty('textinstructions') || params.hasOwnProperty('imginstructions')) {
Expand Down