diff --git a/README.md b/README.md
index 039a634..e0ba989 100644
--- a/README.md
+++ b/README.md
@@ -51,6 +51,7 @@ Examples of API requests for different captcha types are available on the [JavaS
- [Binance](#binance)
- [Audio Captcha](#audio-captcha)
- [Yidun NECaptcha](#yidun-necaptcha)
+ - [Alibaba Captcha](#alibaba-captcha)
- [Other methods](#other-methods)
- [goodReport](#goodreport)
- [badReport](#badreport)
@@ -829,6 +830,35 @@ console.log(err);
})
```
+### Alibaba Captcha
+
+[API method description.](https://2captcha.com/2captcha-api#alibaba)
+
+This method can be used to solve Alibaba captcha (Aliyun). Returns a token.
+
+Required parameters: `pageurl`, `sceneId`, `prefix`.
+
+```js
+solver.alibaba({
+ pageurl: "https://www.example.com",
+ sceneId: "abc123xyz4",
+ prefix: "dlw3kug",
+ user_id: "Abc123Def456Ghi789Jkl012Mno345Pqr678Stu901=",
+ user_user_id: "Xyz987Abc654Def321Ghi098Jkl765Mno432Pqr109=",
+ verifyType: "1.0",
+ region: "sgp",
+ userCertifyId: "abc123def456ghi789jkl012mno345pq",
+ apiGetLib: "https://o.example.com/captcha-frontend/aliyunCaptcha/AliyunCaptcha.js?t=2041",
+ userAgent: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.0.0 Safari/537.36"
+})
+.then((res) => {
+console.log(res);
+})
+.catch((err) => {
+console.log(err);
+})
+```
+
## Other methods
### goodReport
diff --git a/examples/alibabaCaptcha.js b/examples/alibabaCaptcha.js
new file mode 100644
index 0000000..7683ccc
--- /dev/null
+++ b/examples/alibabaCaptcha.js
@@ -0,0 +1,25 @@
+const TwoCaptcha = require("../dist/index.js");
+require('dotenv').config();
+const APIKEY = process.env.APIKEY
+const solver = new TwoCaptcha.Solver(APIKEY);
+
+solver.alibaba({
+ pageurl: "https://www.example.com",
+ sceneId: "abc123xyz4",
+ prefix: "dlw3kug",
+ user_id: "Abc123Def456Ghi789Jkl012Mno345Pqr678Stu901=",
+ user_user_id: "Xyz987Abc654Def321Ghi098Jkl765Mno432Pqr109=",
+ verifyType: "1.0",
+ region: "sgp",
+ userCertifyId: "abc123def456ghi789jkl012mno345pq",
+ apiGetLib: "https://o.example.com/captcha-frontend/aliyunCaptcha/AliyunCaptcha.js?t=2041",
+ userAgent: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.0.0 Safari/537.36",
+ proxy: "login:password@1.2.3.4:8080",
+ proxytype: "HTTP"
+})
+.then((res) => {
+console.log(res);
+})
+.catch((err) => {
+console.log(err);
+})
diff --git a/package.json b/package.json
index 7eaee82..532beaa 100644
--- a/package.json
+++ b/package.json
@@ -56,7 +56,8 @@
"Altcha",
"Binance",
"Audio Recognition",
- "Yidun NECaptcha"
+ "Yidun NECaptcha",
+ "Alibaba Captcha"
],
"scripts": {
"build": "tsc && node ./dist/index.js",
diff --git a/src/structs/2captcha.ts b/src/structs/2captcha.ts
index 1713904..3a314a6 100644
--- a/src/structs/2captcha.ts
+++ b/src/structs/2captcha.ts
@@ -338,6 +338,21 @@ export interface paramsYidun {
proxytype?: string,
}
+export interface paramsAlibaba {
+ pageurl: string,
+ sceneId: string,
+ prefix: string,
+ user_id?: string,
+ user_user_id?: string,
+ verifyType?: string,
+ region?: string,
+ userCertifyId?: string,
+ apiGetLib?: string,
+ userAgent?: string,
+ proxy?: string,
+ proxytype?: string,
+}
+
/**
* An object containing properties of the captcha solution.
* @typedef {Object} CaptchaAnswer
@@ -2416,6 +2431,77 @@ public async yidun(params: paramsYidun): Promise {
}
}
+/**
+ * ### Solves Alibaba Captcha
+ *
+ * This method can be used to solve Alibaba captcha (Aliyun). Returns a token.
+ * [Read more about Alibaba Captcha Method](https://2captcha.com/2captcha-api#alibaba).
+ *
+ * @param {{ pageurl, sceneId, prefix, user_id, user_user_id, verifyType, region, userCertifyId, apiGetLib, userAgent, proxy, proxytype }} params Parameters Alibaba Captcha as an object.
+ * @param {string} params.pageurl Full URL of the page where you see the captcha.
+ * @param {string} params.sceneId Value of `sceneId` parameter found in the captcha request on the page.
+ * @param {string} params.prefix Prefix from the subdomain of the captcha load request URL. For example: `dlw3kug` from `https://dlw3kug.captcha-open.example.aliyuncs.com/`.
+ * @param {string} params.user_id Optional. User or session identifier on the target site.
+ * @param {string} params.user_user_id Optional. Additional user identifier.
+ * @param {string} params.verifyType Optional. Version or type of the verification mechanism.
+ * @param {string} params.region Optional. Captcha processing region, e.g. `sgp`.
+ * @param {string} params.userCertifyId Optional. Verification ID of the current captcha session (`traceid` from the captcha request).
+ * @param {string} params.apiGetLib Optional. URL of the Alibaba Captcha JavaScript library (`AliyunCaptcha.js`).
+ * @param {string} params.userAgent Optional. Browser User-Agent string.
+ * @param {string} params.proxy Optional. 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 Optional. Type of your proxy: `HTTP`, `HTTPS`, `SOCKS4`, `SOCKS5`.
+ *
+ * @returns {Promise} The result from the solve.
+ * @throws APIError
+ *
+ * @example
+ * solver.alibaba({
+ * pageurl: "https://www.example.com",
+ * sceneId: "abc123xyz4",
+ * prefix: "dlw3kug",
+ * region: "sgp",
+ * apiGetLib: "https://o.example.com/captcha-frontend/aliyunCaptcha/AliyunCaptcha.js?t=2041",
+ * userAgent: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.0.0 Safari/537.36"
+ * })
+ * .then((res) => {
+ * console.log(res);
+ * })
+ * .catch((err) => {
+ * console.log(err);
+ * })
+ */
+public async alibaba(params: paramsAlibaba): Promise {
+ params = renameParams(params)
+
+ checkCaptchaParams(params, "alibaba")
+
+ const payload = {
+ ...this.defaultPayload,
+ ...params,
+ method: "alibaba",
+ };
+
+ 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)
+ }
+}
+
/**
* Reports a captcha as correctly solved.
*
diff --git a/src/utils/checkCaptchaParams.ts b/src/utils/checkCaptchaParams.ts
index bafc379..594a2a2 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', 'binance', 'audio', 'yidun']
+ 'textcaptcha', 'canvas', 'rotatecaptcha', 'keycaptcha', 'cutcaptcha', 'tencent', 'atb_captcha', 'prosopo', 'captchafox', 'vkimage', 'vkcaptcha', 'temu', 'altcha', 'binance', 'audio', 'yidun', 'alibaba']
// Names of required fields that must be contained in the parameters captcha
const recaptchaRequiredFields = ['pageurl','googlekey']
@@ -38,6 +38,7 @@ const altchaRequiredFields = ['pageurl']
const binanceRequiredFields = ['pageurl', 'sitekey', 'validate_id']
const audioRequiredFields = ['body', 'lang']
const yidunRequiredFields = ['pageurl', 'sitekey']
+const alibabaRequiredFields = ['pageurl', 'scene_id', 'prefix']
/**
* Getting required arguments for a captcha.
@@ -148,6 +149,9 @@ const getRequiredFildsArr = (method: string):Array => {
case "yidun":
requiredFieldsArr = yidunRequiredFields
break;
+ case "alibaba":
+ requiredFieldsArr = alibabaRequiredFields
+ break;
}
return requiredFieldsArr
}
diff --git a/src/utils/renameParams.ts b/src/utils/renameParams.ts
index 8d84f12..c34db86 100644
--- a/src/utils/renameParams.ts
+++ b/src/utils/renameParams.ts
@@ -50,7 +50,13 @@ export default function renameParams(params: any) {
// Yidun
"yidunGetLib": "yidun_get_lib",
- "yidunApiServerSubdomain": "yidun_api_server_subdomain"
+ "yidunApiServerSubdomain": "yidun_api_server_subdomain",
+
+ // Alibaba
+ "sceneId": "scene_id",
+ "verifyType": "verify_type",
+ "userCertifyId": "user_certify_id",
+ "apiGetLib": "api_get_lib"
}
for(let key in params) {