diff --git a/README.md b/README.md index 9129abc..a40a4a2 100644 --- a/README.md +++ b/README.md @@ -48,6 +48,7 @@ Examples of API requests for different captcha types are available on the [JavaS - [VkCaptcha](#vkcaptcha) - [Temu](#temu) - [Altcha](#altcha) + - [Binance](#binance) - [Audio Captcha](#audio-captcha) - [Other methods](#other-methods) - [goodReport](#goodreport) @@ -758,6 +759,29 @@ console.log(err); }) ``` +### Binance + +[API method description.](https://2captcha.com/2captcha-api#binance) + +This method can be used to solve Binance captcha. Returns a token. + +```js +solver.binance({ + pageurl: "https://mysite.com/page/with/binance", + sitekey: "register", + validateId: "0a05453c44e2411195c0d0c15654d966", + userAgent: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36", + proxy: "login:password@1.2.3.4:8888", + proxytype: "HTTP" +}) +.then((res) => { +console.log(res); +}) +.catch((err) => { +console.log(err); +}) +``` + ### Audio Captcha [API method description.](https://2captcha.com/2captcha-api#audio-recognition) diff --git a/examples/binance.js b/examples/binance.js new file mode 100644 index 0000000..e5c61d1 --- /dev/null +++ b/examples/binance.js @@ -0,0 +1,21 @@ +const TwoCaptcha = require("../dist/index.js"); +require('dotenv').config(); +const APIKEY = process.env.APIKEY +const proxy = process.env.proxy +const proxytype = process.env.proxytype +const solver = new TwoCaptcha.Solver(APIKEY); + +solver.binance({ + pageurl: "https://mysite.com/page/with/binance", + sitekey: "register", + validateId: "0a05453c44e2411195c0d0c15654d966", + userAgent: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36", + proxy: "login:password@1.2.3.4:8888", + proxytype: "HTTP" +}) +.then((res) => { +console.log(res); +}) +.catch((err) => { +console.log(err); +}) \ No newline at end of file diff --git a/package.json b/package.json index b9f4d57..6db36e6 100644 --- a/package.json +++ b/package.json @@ -53,6 +53,8 @@ "VkCaptcha", "Temu", "atbCAPTCHA", + "Altcha", + "Binance", "Audio Recognition" ], "scripts": { diff --git a/src/structs/2captcha.ts b/src/structs/2captcha.ts index 33dd4ee..f62d353 100644 --- a/src/structs/2captcha.ts +++ b/src/structs/2captcha.ts @@ -310,6 +310,15 @@ export interface paramsAltcha { proxytype?: string, } +export interface paramsBinance { + pageurl: string, + sitekey: string, + validateId: string, + userAgent?: string, + proxy?: string, + proxytype?: string, +} + export interface paramsAudioCaptcha { body: string, lang: string, @@ -2211,6 +2220,68 @@ public async altcha(params: paramsAltcha): Promise { } } + +/** + * ### Solves Binance Captcha + * + * This method can be used to solve Binance captcha. Returns a token. + * [Read more about Binance Method](https://2captcha.com/2captcha-api#binance). + * + * @param {{ pageurl, sitekey, validateId, userAgent, proxy, proxytype}} params Parameters Binance as an object. + * @param {string} params.pageurl Full URL of the page where you solve the captcha. + * @param {string} params.sitekey Value of 'bizId', 'bizType', or 'bizCode' from page requests. + * @param {string} params.validateId Dynamic value of 'validateId', 'securityId', or 'securityCheckResponseValidateId'. + * @param {string} params.userAgent Browser User-Agent. We recommend sending a valid Windows browser string. + * @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.binance({ + * pageurl: "https://mysite.com/page/with/binance", + * sitekey: "register", + * validateId: "0a05453c44e2411195c0d0c15654d966", + * }) + * .then((res) => { + * console.log(res); + * }) + * .catch((err) => { + * console.log(err); + * }) + */ + +public async binance(params: paramsBinance): Promise { + params = renameParams(params) + + checkCaptchaParams(params, "binance") + + const payload = { + ...this.defaultPayload, + ...params, + method: "binance", + }; + + const response = await fetch(this.in, { + body: JSON.stringify(payload), + method: "post", + headers: { "Content-Type": "application/json" } + }) + const result = await response.text() + + let data; + try { + data = JSON.parse(result) + } catch { + throw new APIError(result) + } + + if (data.status == 1) { + return this.pollResponse(data.request) + } else { + throw new APIError(data.request) + } +} + + /** * ### Method for solving Audio captcha. * diff --git a/src/utils/checkCaptchaParams.ts b/src/utils/checkCaptchaParams.ts index 52933b7..18bb43a 100644 --- a/src/utils/checkCaptchaParams.ts +++ b/src/utils/checkCaptchaParams.ts @@ -1,7 +1,7 @@ // Captcha methods for which parameter checking is available const supportedMethods = ["userrecaptcha", "hcaptcha", "geetest", "geetest_v4","yandex","funcaptcha","lemin","amazon_waf", "turnstile", "base64", "capy","datadome", "cybersiara", "mt_captcha", "bounding_box", 'friendly_captcha', 'grid', - 'textcaptcha', 'canvas', 'rotatecaptcha', 'keycaptcha', 'cutcaptcha', 'tencent', 'atb_captcha', 'prosopo', 'captchafox', 'vkimage', 'vkcaptcha', 'temu', 'altcha', 'audio'] + 'textcaptcha', 'canvas', 'rotatecaptcha', 'keycaptcha', 'cutcaptcha', 'tencent', 'atb_captcha', 'prosopo', 'captchafox', 'vkimage', 'vkcaptcha', 'temu', 'altcha', 'binance', 'audio'] // Names of required fields that must be contained in the parameters captcha const recaptchaRequiredFields = ['pageurl','googlekey'] @@ -35,6 +35,7 @@ const vkimageRequiredFields = ['body', 'steps'] const vkcaptchaRequiredFields = ['redirect_uri', 'userAgent', 'proxy', 'proxytype'] const temuRequiredFields = ['body', 'part1', 'part2', 'part3'] const altchaRequiredFields = ['pageurl'] +const binanceRequiredFields = ['pageurl', 'sitekey', 'validate_id'] const audioRequiredFields = ['body', 'lang'] /** @@ -137,6 +138,9 @@ const getRequiredFildsArr = (method: string):Array => { case "altcha": requiredFieldsArr = altchaRequiredFields break; + case "binance": + requiredFieldsArr = binanceRequiredFields + break; case "audio": requiredFieldsArr = audioRequiredFields break; diff --git a/src/utils/renameParams.ts b/src/utils/renameParams.ts index 4fce3d0..7d7bb7d 100644 --- a/src/utils/renameParams.ts +++ b/src/utils/renameParams.ts @@ -43,6 +43,10 @@ export default function renameParams(params: any) { // Altcha "challengeUrl": "challenge_url", "challengeJson": "challenge_json", + + //Binance + "validateId": "validate_id", + "userAgent": "useragent" } for(let key in params) {