UNPKG

@captcha-libs/twocaptcha

Version:

TwoCaptcha NodeJS client, captcha recognition service

1,043 lines (1,018 loc) 143 kB
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }var __defProp = Object.defineProperty; var __defProps = Object.defineProperties; var __getOwnPropDescs = Object.getOwnPropertyDescriptors; var __getOwnPropSymbols = Object.getOwnPropertySymbols; var __hasOwnProp = Object.prototype.hasOwnProperty; var __propIsEnum = Object.prototype.propertyIsEnumerable; var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; var __spreadValues = (a, b) => { for (var prop in b || (b = {})) if (__hasOwnProp.call(b, prop)) __defNormalProp(a, prop, b[prop]); if (__getOwnPropSymbols) for (var prop of __getOwnPropSymbols(b)) { if (__propIsEnum.call(b, prop)) __defNormalProp(a, prop, b[prop]); } return a; }; var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b)); var __name = (target, value) => __defProp(target, "name", { value, configurable: true }); var __objRest = (source, exclude) => { var target = {}; for (var prop in source) if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0) target[prop] = source[prop]; if (source != null && __getOwnPropSymbols) for (var prop of __getOwnPropSymbols(source)) { if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop)) target[prop] = source[prop]; } return target; }; var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value); var __async = (__this, __arguments, generator) => { return new Promise((resolve, reject) => { var fulfilled = (value) => { try { step(generator.next(value)); } catch (e) { reject(e); } }; var rejected = (value) => { try { step(generator.throw(value)); } catch (e) { reject(e); } }; var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected); step((generator = generator.apply(__this, __arguments)).next()); }); }; // ../captcha-client/src/captcha-client.ts var _CaptchaClient = class _CaptchaClient { }; __name(_CaptchaClient, "CaptchaClient"); __publicField(_CaptchaClient, "baseUrl"); var CaptchaClient = _CaptchaClient; // ../captcha-client/src/utils.ts var delay = /* @__PURE__ */ __name((timeout) => __async(void 0, null, function* () { return yield new Promise((resolve) => setTimeout(resolve, timeout)); }), "delay"); // src/lib/twocaptcha.ts var _nodefetch = require('node-fetch'); var _nodefetch2 = _interopRequireDefault(_nodefetch); var _TwoCaptcha = class _TwoCaptcha extends CaptchaClient { /** * @param {object} [params] - CaptchaClientParams * @param {string} [params.clientKey] - YOUR_API_KEY from dashboard * @param {number} [params.timeout] - max timeout to getTaskResult * @param {number} [params.pollingInterval] - polling interval to getTaskResult */ constructor(params) { const { clientKey, timeout = 12e4, pollingInterval = 5e3 } = params; super(); /** * @type {string} clientKey - YOUR_API_KEY from dashboard */ __publicField(this, "clientKey"); /** * @type {number} pollingInterval - polling interval to getTaskResult in ms. Default to 5000 */ __publicField(this, "pollingInterval"); /** * @type {number} timeout - max timeout to getTaskResult in ms. Default to 120_000 */ __publicField(this, "timeout"); /** * @type {string} baseUrl - api base url */ __publicField(this, "baseUrl", "https://api.2captcha.com"); this.clientKey = clientKey; this.pollingInterval = pollingInterval; this.timeout = timeout; } getBalance() { return __async(this, null, function* () { const body = yield _nodefetch2.default.call(void 0, `${this.baseUrl}/getBalance`, { "body": JSON.stringify({ "clientKey": this.clientKey }), "method": "POST" }); const response = yield body.json(); const _a = response, { errorId } = _a, getBalanceResponse = __objRest(_a, ["errorId"]); if (errorId && "errorDescription" in getBalanceResponse) throw new Error(`TwoCaptcha: ${getBalanceResponse.errorDescription}`); if (!("balance" in getBalanceResponse)) throw new Error("TwoCaptcha: unknown error"); return getBalanceResponse.balance; }); } /** * @param {object} request - task payload to create task * @return {Promise<TwoCaptchaCreateTaskResponse>} - response of createTask */ createTask(request) { return __async(this, null, function* () { const body = yield _nodefetch2.default.call(void 0, `${this.baseUrl}/createTask`, { "body": JSON.stringify({ "clientKey": this.clientKey, "task": request }), "method": "POST" }); const response = yield body.json(); if (!("taskId" in response)) throw new Error(`TwoCaptcha: ${response.errorCode}. ${response.errorDescription}`); return response; }); } /** * The method is used for automated feedback on captcha solutions. * Make this request if the answer was declined by the target website. * We use the collected statistics to improve our service, * we check the solutions, we check workers who provided the solution * and after the analysis we issue refunds for incorrectly solved captchas. * If your success rate is close to 0% please do not send this request, there is definitely wrong with your code/software. * @see {@link https://2captcha.com/api-docs/report-incorrect} * @param {number} taskId - The id of your task * @return {Promise<TwoCaptchaReportTaskSuccessResponse>} - response of createTask */ reportIncorrect(taskId) { return __async(this, null, function* () { const body = yield _nodefetch2.default.call(void 0, `${this.baseUrl}/reportIncorrect`, { "body": JSON.stringify({ "clientKey": this.clientKey, taskId }), "method": "POST" }); const response = yield body.json(); if (!("status" in response)) throw new Error(`TwoCaptcha: ${response.errorCode}. ${response.errorDescription}`); return response; }); } /** * The method is used for automated feedback on captcha solutions. * If the answer was accepted by the target website send this request. * We use the collected statistics to make our service better. * @see {@link https://2captcha.com/api-docs/report-correct} * @param {number} taskId - The id of your task * @return {Promise<TwoCaptchaReportTaskSuccessResponse>} - response of createTask */ reportCorrect(taskId) { return __async(this, null, function* () { const body = yield _nodefetch2.default.call(void 0, `${this.baseUrl}/reportCorrect`, { "body": JSON.stringify({ "clientKey": this.clientKey, taskId }), "method": "POST" }); const response = yield body.json(); if (!("status" in response)) throw new Error(`TwoCaptcha: ${response.errorCode}. ${response.errorDescription}`); return response; }); } /** * @param {Requests} request - task payload to create task or taskProxyless * @return {Promise<TwoCaptchaSuccessSolution<TSolution>>} - response of createTask */ solve(request) { return __async(this, null, function* () { const _a = __spreadValues({ "_isAmazonTask": false, "_isAmazonTaskProxyless": false, "_isAntiCyberSiAraTask": false, "_isAntiCyberSiAraTaskProxyless": false, "_isCapyTask": false, "_CutCaptchaTask": false, "_isCapyTaskProxyless": false, "_isCutCaptchaTaskProxyless": false, "_isDataDomeSliderTask": false, "_isFriendlyCaptchaTask": false, "_isFriendlyCaptchaTaskProxyless": false, "_isFunCaptchaTask": false, "_isFunCaptchaTaskProxyless": false, "_isGeeTestTask": false, "_isGeeTestTaskProxyless": false, "_isGeeTestV3Task": false, "_isGeeTestV3TaskProxyless": false, "_isGeeTestV4Task": false, "_isGeeTestV4TaskProxyless": false, "_isGridTask": false, "_isHCaptchaTask": false, "_isHCaptchaTaskProxyless": false, "_isImageToTextTask": false, "_isKeyCaptchaTask": false, "_isKeyCaptchaTaskProxyless": false, "_isLeminTask": false, "_isLeminTaskProxyless": false, "_isMtCaptchaTask": false, "_isMtCaptchaTaskProxyless": false, "_isRecaptchaV2EnterpriseTask": false, "_isRecaptchaV2EnterpriseTaskProxyless": false, "_isRecaptchaV2Task": false, "_isRecaptchaV2TaskProxyless": false, "_isRecaptchaV3TaskProxyless": false, "_isRequests": false, "_isRotateTask": false, "_isTextCaptchaTask": false, "_isTurnstileTask": false, "_isTurnstileTaskProxyless": false, "_isAudioTask": false, "_isBoundingBoxTask": false, "_isCoordinatesTask": false, "_isDrawAroundTask": false, "_isAtbCaptchaTask": false, "_isAtbCaptchaTaskProxyless": false, "_isTencentTask": false, "_isTencentTaskProxyless": false }, request), { _isAmazonTask = false, _isAmazonTaskProxyless = false, _isAntiCyberSiAraTask = false, _isAntiCyberSiAraTaskProxyless = false, _isCapyTask = false, _CutCaptchaTask: _CutCaptchaTask2 = false, _isCapyTaskProxyless = false, _isCutCaptchaTaskProxyless = false, _isDataDomeSliderTask = false, _isFriendlyCaptchaTask = false, _isFriendlyCaptchaTaskProxyless = false, _isFunCaptchaTask = false, _isFunCaptchaTaskProxyless = false, _isGeeTestTask = false, _isGeeTestTaskProxyless = false, _isGeeTestV3Task = false, _isGeeTestV3TaskProxyless = false, _isGeeTestV4Task = false, _isGeeTestV4TaskProxyless = false, _isGridTask = false, _isHCaptchaTask = false, _isHCaptchaTaskProxyless = false, _isImageToTextTask = false, _isKeyCaptchaTask = false, _isKeyCaptchaTaskProxyless = false, _isLeminTask = false, _isLeminTaskProxyless = false, _isMtCaptchaTask = false, _isMtCaptchaTaskProxyless = false, _isRecaptchaV2EnterpriseTask = false, _isRecaptchaV2EnterpriseTaskProxyless = false, _isRecaptchaV2Task = false, _isRecaptchaV2TaskProxyless = false, _isRecaptchaV3TaskProxyless = false, _isRequests = false, _isRotateTask = false, _isTextCaptchaTask = false, _isTurnstileTask = false, _isTurnstileTaskProxyless = false, _isAudioTask = false, _isBoundingBoxTask = false, _isCoordinatesTask = false, _isDrawAroundTask = false, _isAtbCaptchaTask = false, _isAtbCaptchaTaskProxyless = false, _isTencentTask = false, _isTencentTaskProxyless = false } = _a, payload = __objRest(_a, ["_isAmazonTask", "_isAmazonTaskProxyless", "_isAntiCyberSiAraTask", "_isAntiCyberSiAraTaskProxyless", "_isCapyTask", "_CutCaptchaTask", "_isCapyTaskProxyless", "_isCutCaptchaTaskProxyless", "_isDataDomeSliderTask", "_isFriendlyCaptchaTask", "_isFriendlyCaptchaTaskProxyless", "_isFunCaptchaTask", "_isFunCaptchaTaskProxyless", "_isGeeTestTask", "_isGeeTestTaskProxyless", "_isGeeTestV3Task", "_isGeeTestV3TaskProxyless", "_isGeeTestV4Task", "_isGeeTestV4TaskProxyless", "_isGridTask", "_isHCaptchaTask", "_isHCaptchaTaskProxyless", "_isImageToTextTask", "_isKeyCaptchaTask", "_isKeyCaptchaTaskProxyless", "_isLeminTask", "_isLeminTaskProxyless", "_isMtCaptchaTask", "_isMtCaptchaTaskProxyless", "_isRecaptchaV2EnterpriseTask", "_isRecaptchaV2EnterpriseTaskProxyless", "_isRecaptchaV2Task", "_isRecaptchaV2TaskProxyless", "_isRecaptchaV3TaskProxyless", "_isRequests", "_isRotateTask", "_isTextCaptchaTask", "_isTurnstileTask", "_isTurnstileTaskProxyless", "_isAudioTask", "_isBoundingBoxTask", "_isCoordinatesTask", "_isDrawAroundTask", "_isAtbCaptchaTask", "_isAtbCaptchaTaskProxyless", "_isTencentTask", "_isTencentTaskProxyless"]); const balance = yield this.getBalance(); if (!balance) throw new Error("TwoCaptcha: ERROR_ZERO_BALANCE"); const createTaskResponse = yield this.createTask(payload); const abortSignal = AbortSignal.timeout(this.timeout); const isAborted = abortSignal.aborted; try { while (!isAborted) { const body = yield _nodefetch2.default.call(void 0, `${this.baseUrl}/getTaskResult`, { "body": JSON.stringify({ "clientKey": this.clientKey, "taskId": createTaskResponse.taskId }), "method": "POST", "signal": abortSignal }); const response = yield body.json(); if ("solution" in response) { return __spreadProps(__spreadValues({}, response), { "taskId": createTaskResponse.taskId }); } else if (response.errorId) { throw new Error(`TwoCaptcha: ${response.errorDescription}`); } yield delay(this.pollingInterval); } } catch (error) { if (error instanceof _nodefetch.AbortError && error.name === "AbortError") throw new Error(`TwoCaptcha timeout ${this.timeout} exceeded!`); else throw error; } throw new Error("TwoCaptcha finished with error"); }); } }; __name(_TwoCaptcha, "TwoCaptcha"); var TwoCaptcha = _TwoCaptcha; // src/lib/Requests/_BaseTaskRequest.ts var _BaseTask = class _BaseTask { constructor({ type }) { /** * @type {TaskTypes} type - task type */ __publicField(this, "type"); this.type = type; } }; __name(_BaseTask, "BaseTask"); var BaseTask = _BaseTask; // src/lib/Requests/Recognition/TextCaptchaTask.ts var _TextCaptchaTask = class _TextCaptchaTask extends BaseTask { /** * Create TextCaptchaTask * @see {@link https://2captcha.com/api-docs/text} * @param {Object} params - TextCaptchaParams * @param {string} [params.comment] - Text with a question you need to answer. */ constructor({ comment }) { super({ "type": "TextCaptchaTask" }); /** * @type {string} comment - Text with a question you need to answer. */ __publicField(this, "comment"); /** * @type {boolean} _isTextCaptchaTask - Only used for correct method overloading intellisense */ __publicField(this, "_isTextCaptchaTask", true); this.comment = comment; } }; __name(_TextCaptchaTask, "TextCaptchaTask"); var TextCaptchaTask = _TextCaptchaTask; // src/lib/Requests/Recognition/RotateTask.ts var _RotateTask = class _RotateTask extends BaseTask { /** * Create RotateTask * @see {@link https://2captcha.com/api-docs/rotate} * @param {Object} params - RotateTaskParams * @param {string} [params.body] - Image encoded into Base64 format. Data-URI format (containing data:content/type prefix) is also supported * @param {string=} [params.comment] - A comment will be shown to workers to help them to solve the captcha properly * @param {string=} [params.angle] - One step rotation angle. You can count how many steps are required to rotate the image 360 degrees and then divide 360 by this count to get the angle value * @type {string} [params.imgInstructions] - An optional image with instruction that will be shown to workers. Image should be encoded into Base64 format. Max file size: 100 kB */ constructor({ body, comment, angle, imgInstructions }) { super({ "type": "RotateTask" }); /** * @type {string} comment - A comment will be shown to workers to help them to solve the captcha properly */ __publicField(this, "comment"); /** * @type {string} body - Image encoded into Base64 format. Data-URI format (containing data:content/type prefix) is also supported */ __publicField(this, "body"); /** * @type {number} angle - One step rotation angle. You can count how many steps are required to rotate the image 360 degrees and then divide 360 by this count to get the angle value */ __publicField(this, "angle"); /** * @type {string} imgInstructions - An optional image with instruction that will be shown to workers. Image should be encoded into Base64 format. Max file size: 100 kB */ __publicField(this, "imgInstructions"); /** * @type {boolean} _isRotateTask - Only used for correct method overloading intellisense */ __publicField(this, "_isRotateTask", true); this.body = body; this.comment = comment; this.angle = angle; this.imgInstructions = imgInstructions; } }; __name(_RotateTask, "RotateTask"); var RotateTask = _RotateTask; // src/lib/Requests/Recognition/ImageToTextTask.ts var NumericOptions; (function(NumericOptions2) { NumericOptions2[NumericOptions2["none"] = 0] = "none"; NumericOptions2[NumericOptions2["onlyNumbers"] = 1] = "onlyNumbers"; NumericOptions2[NumericOptions2["onlyLetters"] = 2] = "onlyLetters"; NumericOptions2[NumericOptions2["numbersOrLetters"] = 3] = "numbersOrLetters"; NumericOptions2[NumericOptions2["numbersAndLetters"] = 4] = "numbersAndLetters"; })(NumericOptions || (NumericOptions = {})); var _ImageToTextTask = class _ImageToTextTask extends BaseTask { /** * Create ImageToTextTask * @see {@link https://2captcha.com/api-docs/normal-captcha} * @param {Object} params - ImageToTextParams * @param {string} [params.body] - Image encoded into Base64 format. Data-URI format (containing data:content/type prefix) is also supported * @param {boolean=} [params.case] - Case sensitive or not * @param {string=} [params.comment] - A comment will be shown to workers to help them to solve the captcha properly * @param {string=} [params.imgInstructions] - An optional image with instruction that will be shown to workers. Image should be encoded into Base64 format. * @param {boolean=} [params.math] - captcha requires calculation * @param {number=} [params.maxLength] - defines maximal answer length * @param {number=} [params.minLength] - defines minimal answer length * @param {NumericOptions=} [params.numeric] - Numeric preference * @param {boolean=} [params.phrase] - The answer should contain at least two words separated by space. */ constructor({ body, "case": _case, comment, imgInstructions, math, maxLength, minLength, numeric, phrase }) { super({ "type": "ImageToTextTask" }); /** * @type {string} body - Image encoded into Base64 format. Data-URI format (containing data:content/type prefix) is also supported */ __publicField(this, "body"); /** * @type {string} case - Case sensitive or not */ __publicField(this, "case"); /** * @type {string} comment - A comment will be shown to workers to help them to solve the captcha properly */ __publicField(this, "comment"); /** * @type {string} imgInstructions - An optional image with instruction that will be shown to workers. Image should be encoded into Base64 format. */ __publicField(this, "imgInstructions"); /** * @type {string} math - Captcha requires calculation */ __publicField(this, "math"); /** * @type {number} maxLength - defines maximal answer length */ __publicField(this, "maxLength"); /** * @type {number} maxLength - defines minimal answer length */ __publicField(this, "minLength"); /** * @type {number} maxLength - Numeric preference */ __publicField(this, "numeric"); /** * @type {number} maxLength - The answer should contain at least two words separated by space. */ __publicField(this, "phrase"); /** * @type {boolean} _isImageToTextTask - Only used for correct method overloading intellisense */ __publicField(this, "_isImageToTextTask", true); this.body = body; this.case = _case; this.comment = comment; this.imgInstructions = imgInstructions; this.math = math; this.maxLength = maxLength; this.minLength = minLength; this.numeric = numeric; this.phrase = phrase; } }; __name(_ImageToTextTask, "ImageToTextTask"); var ImageToTextTask = _ImageToTextTask; // src/lib/Requests/Recognition/GridTask.ts var _GridTask = class _GridTask extends BaseTask { /** * Create GridTask * @see {@link https://2captcha.com/api-docs/grid} * @param {Object} params - GridTaskParams * @param {string} [params.body] - Image encoded into Base64 format. Data-URI format (containing data:content/type prefix) is also supported * @param {string=} [params.comment] - A comment will be shown to workers to help them to solve the captcha properly * @param {string} [params.imgInstructions] - An optional image with instruction that will be shown to workers. Image should be encoded into Base64 format. Max file size: 100 kB * @param {number} [params.rows] - Number of grid rows * @param {number} [params.columns] - Number of grid columns */ constructor({ body, comment, imgInstructions, columns, rows }) { super({ "type": "GridTask" }); /** * @type {string} comment - A comment will be shown to workers to help them to solve the captcha properly */ __publicField(this, "comment"); /** * @type {string} body - Image encoded into Base64 format. Data-URI format (containing data:content/type prefix) is also supported */ __publicField(this, "body"); /** * @type {string} imgInstructions - An optional image with instruction that will be shown to workers. Image should be encoded into Base64 format. Max file size: 100 kB */ __publicField(this, "imgInstructions"); /** * @type {number} rows - Number of grid rows */ __publicField(this, "rows"); /** * @type {number} columns - Number of grid columns */ __publicField(this, "columns"); /** * @type {boolean} _isGridTask - Only used for correct method overloading intellisense */ __publicField(this, "_isGridTask", true); this.body = body; this.comment = comment; this.imgInstructions = imgInstructions; this.rows = rows; this.columns = columns; } }; __name(_GridTask, "GridTask"); var GridTask = _GridTask; // src/lib/Requests/Recognition/DrawAroundTask.ts var _DrawAroundTask = class _DrawAroundTask extends BaseTask { /** * Create DrawAroundTask * @see {@link https://2captcha.com/api-docs/draw-around} * @param {Object} params - DrawAroundTaskParams * @param {string} [params.body] - Image encoded into Base64 format. Data-URI format (containing data:content/type prefix) is also supported * @param {string=} [params.comment] - A comment will be shown to workers to help them to solve the captcha properly * @type {string} [params.imgInstructions] - An optional image with instruction that will be shown to workers. Image should be encoded into Base64 format. Max file size: 100 kB */ constructor({ body, comment, imgInstructions }) { super({ "type": "DrawAroundTask" }); /** * @type {string} comment - A comment will be shown to workers to help them to solve the captcha properly */ __publicField(this, "comment"); /** * @type {string} body - Image encoded into Base64 format. Data-URI format (containing data:content/type prefix) is also supported */ __publicField(this, "body"); /** * @type {string} imgInstructions - An optional image with instruction that will be shown to workers. Image should be encoded into Base64 format. Max file size: 100 kB */ __publicField(this, "imgInstructions"); /** * @type {boolean} _isDrawAroundTask - Only used for correct method overloading intellisense */ __publicField(this, "_isDrawAroundTask", true); this.body = body; this.comment = comment; this.imgInstructions = imgInstructions; } }; __name(_DrawAroundTask, "DrawAroundTask"); var DrawAroundTask = _DrawAroundTask; // src/lib/Requests/Recognition/CoordinatesTask.ts var _CoordinatesTask = class _CoordinatesTask extends BaseTask { /** * Create CoordinatesTask * @see {@link https://2captcha.com/api-docs/coordinates} * @param {Object} params - CoordinatesTaskParams * @param {string} [params.body] - Image encoded into Base64 format. Data-URI format (containing data:content/type prefix) is also supported * @param {string=} [params.comment] - A comment will be shown to workers to help them to solve the captcha properly * @param {string} [params.imgInstructions] - An optional image with instruction that will be shown to workers. Image should be encoded into Base64 format. Max file size: 100 kB */ constructor({ body, comment, imgInstructions }) { super({ "type": "CoordinatesTask" }); /** * @type {string} comment - A comment will be shown to workers to help them to solve the captcha properly */ __publicField(this, "comment"); /** * @type {string} body - Image encoded into Base64 format. Data-URI format (containing data:content/type prefix) is also supported */ __publicField(this, "body"); /** * @type {string} imgInstructions - An optional image with instruction that will be shown to workers. Image should be encoded into Base64 format. Max file size: 100 kB */ __publicField(this, "imgInstructions"); /** * @type {boolean} _isCoordinatesTask - Only used for correct method overloading intellisense */ __publicField(this, "_isCoordinatesTask", true); this.body = body; this.comment = comment; this.imgInstructions = imgInstructions; } }; __name(_CoordinatesTask, "CoordinatesTask"); var CoordinatesTask = _CoordinatesTask; // src/lib/Requests/Recognition/BoundingBoxTask.ts var _BoundingBoxTask = class _BoundingBoxTask extends BaseTask { /** * Create BoundingBoxTask * @see {@link https://2captcha.com/api-docs/bounding-box} * @param {Object} params - BoundingBoxTaskParams * @param {string} [params.body] - Image encoded into Base64 format. Data-URI format (containing data:content/type prefix) is also supported * @param {string=} [params.comment] - A comment will be shown to workers to help them to solve the captcha properly * @type {string=} [params.imgInstructions] - An optional image with instruction that will be shown to workers. Image should be encoded into Base64 format. Max file size: 100 kB */ constructor({ body, comment, imgInstructions }) { super({ "type": "BoundingBoxTask" }); /** * @type {string} comment - A comment will be shown to workers to help them to solve the captcha properly */ __publicField(this, "comment"); /** * @type {string} body - Image encoded into Base64 format. Data-URI format (containing data:content/type prefix) is also supported */ __publicField(this, "body"); /** * @type {string} imgInstructions - An optional image with instruction that will be shown to workers. Image should be encoded into Base64 format. Max file size: 100 kB */ __publicField(this, "imgInstructions"); /** * @type {boolean} _isBoundingBoxTask - Only used for correct method overloading intellisense */ __publicField(this, "_isBoundingBoxTask", true); this.body = body; this.comment = comment; this.imgInstructions = imgInstructions; } }; __name(_BoundingBoxTask, "BoundingBoxTask"); var BoundingBoxTask = _BoundingBoxTask; // src/lib/Requests/Recognition/AudioTask.ts var _AudioTask = class _AudioTask extends BaseTask { /** * Create AudioTask * @see {@link https://2captcha.com/api-docs/audio} * @param {Object} params - AudioTaskParams * @param {string} [params.body] - Base64 encoded audio file in mp3 format * @param {string} [params.lang] - The language of audio record. Supported languages are: en, fr, de, el, pt, ru */ constructor({ lang, body }) { super({ "type": "AudioTask" }); /** * @type {string} body - Base64 encoded audio file in mp3 format */ __publicField(this, "body"); /** * @type {string} lang - The language of audio record. Supported languages are: en, fr, de, el, pt, ru */ __publicField(this, "lang"); /** * @type {boolean} _isAudioTask - Only used for correct method overloading intellisense */ __publicField(this, "_isAudioTask", true); this.body = body; this.lang = lang; } }; __name(_AudioTask, "AudioTask"); var AudioTask = _AudioTask; // src/lib/Requests/Token/Base/_TencentTaskBase.ts var _TencentTaskBase = class _TencentTaskBase extends BaseTask { /** * TencentTaskBase * @see {@link https://2captcha.com/api-docs/tencent} * @param {Object} params - TencentTaskParams * @param {string} [params.websiteURL] - The full URL of target web page where the captcha is loaded. We do not open the page, not a problem if it is available only for authenticated users * @param {string} [params.appId] - The TencentTask sitekey value found in the page code. * @param {string} [params.proxyAddress] - Proxy IP address or hostname * @param {string} [params.proxyLogin] - Login for basic authentication on the proxy * @param {string} [params.proxyPassword] - Password for basic authentication on the proxy * @param {string} [params.proxyType] - Type of your proxy: HTTP, HTTPS, SOCKS4, SOCKS5 * @param {string} [params.proxyPort] - Proxy port */ constructor({ appId, websiteURL, proxyAddress, proxyPort, proxyType, proxyLogin, proxyPassword }, type) { super({ type }); /** * @type {string} websiteURL - The full URL of target web page where the captcha is loaded. We do not open the page, not a problem if it is available only for authenticated users */ __publicField(this, "websiteURL"); /** * @type {string} appId - The TencentTask sitekey value found in the page code. */ __publicField(this, "appId"); __publicField(this, "proxyAddress"); __publicField(this, "proxyLogin"); __publicField(this, "proxyPassword"); __publicField(this, "proxyPort"); __publicField(this, "proxyType"); __publicField(this, "proxy"); this.appId = appId; this.websiteURL = websiteURL; this.proxyAddress = proxyAddress; this.proxyLogin = proxyLogin; this.proxyPassword = proxyPassword; this.proxyPort = proxyPort; this.proxyType = proxyType; } }; __name(_TencentTaskBase, "TencentTaskBase"); var TencentTaskBase = _TencentTaskBase; // src/lib/Requests/Token/TencentTaskProxyless.ts var _TencentTaskProxyless = class _TencentTaskProxyless extends TencentTaskBase { /** * Create TencentTaskProxyless * @see {@link https://2captcha.com/api-docs/tencent} * @param {Object} params - TencentTaskProxylessParams * @param {string} [params.websiteURL] - The full URL of target web page where the captcha is loaded. We do not open the page, not a problem if it is available only for authenticated users * @param {string} [params.appId] - The TencentTask sitekey value found in the page code. */ constructor(params) { super(params, "TencentTaskProxyless"); /** * @type {boolean} _isTencentTaskProxyless - Only used for correct method overloading intellisense */ __publicField(this, "_isTencentTaskProxyless", true); } }; __name(_TencentTaskProxyless, "TencentTaskProxyless"); var TencentTaskProxyless = _TencentTaskProxyless; // src/lib/Requests/Token/TencentTask.ts var _TencentTask = class _TencentTask extends TencentTaskBase { /** * Create TencentTask * @see {@link https://2captcha.com/api-docs/tencent} * @param {Object} params - TencentTaskParams * @param {string} [params.websiteURL] - The full URL of target web page where the captcha is loaded. We do not open the page, not a problem if it is available only for authenticated users * @param {string} [params.appId] - The TencentTask sitekey value found in the page code. * @param {string} [params.proxyAddress] - Proxy IP address or hostname * @param {string} [params.proxyLogin] - Login for basic authentication on the proxy * @param {string} [params.proxyPassword] - Password for basic authentication on the proxy * @param {string} [params.proxyType] - Type of your proxy: HTTP, HTTPS, SOCKS4, SOCKS5 * @param {string} [params.proxyPort] - Proxy port */ constructor(params) { super(params, "TencentTask"); /** * @type {boolean} _isTencentTask - Only used for correct method overloading intellisense */ __publicField(this, "_isTencentTask", true); } }; __name(_TencentTask, "TencentTask"); var TencentTask = _TencentTask; // src/lib/Requests/Token/Base/_AtbCaptchaTaskBase.ts var _AtbCaptchaTaskBase = class _AtbCaptchaTaskBase extends BaseTask { /** * AtbCaptchaTaskBase * @see {@link https://2captcha.com/api-docs/atb-captcha} * @param {Object} params - AtbCaptchaTaskParams * @param {string} [params.websiteURL] - The full URL of target web page where the captcha is loaded. We do not open the page, not a problem if it is available only for authenticated users * @param {string} [params.appId] - The value of appId parameter in the website source code. * @param {string} [params.apiServer] - The value of apiServer parameter in the website source code. * @param {string} [params.proxyAddress] - Proxy IP address or hostname * @param {string} [params.proxyLogin] - Login for basic authentication on the proxy * @param {string} [params.proxyPassword] - Password for basic authentication on the proxy * @param {string} [params.proxyType] - Type of your proxy: HTTP, HTTPS, SOCKS4, SOCKS5 * @param {string} [params.proxyPort] - Proxy port */ constructor({ appId, websiteURL, proxyAddress, proxyPort, proxyType, proxyLogin, proxyPassword, apiServer }, type) { super({ type }); /** * @type {string} websiteURL - The full URL of target web page where the captcha is loaded. We do not open the page, not a problem if it is available only for authenticated users */ __publicField(this, "websiteURL"); /** * @type {string} appId - The value of appId parameter in the website source code. */ __publicField(this, "appId"); /** * @type {string} apiServer - The value of apiServer parameter in the website source code. */ __publicField(this, "apiServer"); __publicField(this, "proxyAddress"); __publicField(this, "proxyLogin"); __publicField(this, "proxyPassword"); __publicField(this, "proxyPort"); __publicField(this, "proxyType"); __publicField(this, "proxy"); this.appId = appId; this.websiteURL = websiteURL; this.proxyAddress = proxyAddress; this.proxyLogin = proxyLogin; this.proxyPassword = proxyPassword; this.proxyPort = proxyPort; this.proxyType = proxyType; this.apiServer = apiServer; } }; __name(_AtbCaptchaTaskBase, "AtbCaptchaTaskBase"); var AtbCaptchaTaskBase = _AtbCaptchaTaskBase; // src/lib/Requests/Token/AtbCaptchaTaskProxyless.ts var _AtbCaptchaTaskProxyless = class _AtbCaptchaTaskProxyless extends AtbCaptchaTaskBase { /** * Create AtbCaptchaTaskProxyless * @see {@link https://2captcha.com/api-docs/atb-captcha} * @param {Object} params - AtbCaptchaTaskProxylessParams * @param {string} [params.websiteURL] - The full URL of target web page where the captcha is loaded. We do not open the page, not a problem if it is available only for authenticated users * @param {string} [params.appId] - The value of appId parameter in the website source code. * @param {string} [params.apiServer] - The value of apiServer parameter in the website source code. */ constructor(params) { super(params, "AtbCaptchaTaskProxyless"); /** * @type {boolean} _isAtbCaptchaTaskProxyless - Only used for correct method overloading intellisense */ __publicField(this, "_isAtbCaptchaTaskProxyless", true); } }; __name(_AtbCaptchaTaskProxyless, "AtbCaptchaTaskProxyless"); var AtbCaptchaTaskProxyless = _AtbCaptchaTaskProxyless; // src/lib/Requests/Token/AtbCaptchaTask.ts var _AtbCaptchaTask = class _AtbCaptchaTask extends AtbCaptchaTaskBase { /** * Create AtbCaptchaTask * @see {@link https://2captcha.com/api-docs/atb-captcha} * @param {Object} params - AtbCaptchaTaskParams * @param {string} [params.websiteURL] - The full URL of target web page where the captcha is loaded. We do not open the page, not a problem if it is available only for authenticated users * @param {string} [params.appId] - The value of appId parameter in the website source code. * @param {string} [params.apiServer] - The value of apiServer parameter in the website source code. * @param {string} [params.proxyAddress] - Proxy IP address or hostname * @param {string} [params.proxyLogin] - Login for basic authentication on the proxy * @param {string} [params.proxyPassword] - Password for basic authentication on the proxy * @param {string} [params.proxyType] - Type of your proxy: HTTP, HTTPS, SOCKS4, SOCKS5 * @param {string} [params.proxyPort] - Proxy port */ constructor(params) { super(params, "AtbCaptchaTask"); /** * @type {boolean} _isAtbCaptchaTask - Only used for correct method overloading intellisense */ __publicField(this, "_isAtbCaptchaTask", true); } }; __name(_AtbCaptchaTask, "AtbCaptchaTask"); var AtbCaptchaTask = _AtbCaptchaTask; // src/lib/Requests/Token/Base/_CutCaptchaTask.ts var _CutCaptchaTaskBase = class _CutCaptchaTaskBase extends BaseTask { /** * CutCaptchaTaskBase * @see {@link https://2captcha.com/api-docs/cutcaptcha} * @param {Object} params - CutCaptchaTaskParams * @param {string} [params.websiteURL] - The full URL of target web page where the captcha is loaded. We do not open the page, not a problem if it is available only for authenticated users * @param {string} [params.miseryKey] - The value of CUTCAPTCHA_MISERY_KEY variable defined on page. * @param {string} [params.apiKey] - The value of data-apikey attribute of iframe's body. Also the name of javascript file included on the page * @param {string} [params.userAgent] - User-Agent of your browser will be used to load the captcha. Use only modern browser's User-Agents * @param {string} [params.proxyAddress] - Proxy IP address or hostname * @param {string} [params.proxyLogin] - Login for basic authentication on the proxy * @param {string} [params.proxyPassword] - Password for basic authentication on the proxy * @param {string} [params.proxyType] - Type of your proxy: HTTP, HTTPS, SOCKS4, SOCKS5 * @param {string} [params.proxyPort] - Proxy port */ constructor({ miseryKey, websiteURL, proxyAddress, proxyPort, proxyType, proxyLogin, proxyPassword, apiKey }, type) { super({ type }); /** * @type {string} websiteURL - The full URL of target web page where the captcha is loaded. We do not open the page, not a problem if it is available only for authenticated users */ __publicField(this, "websiteURL"); /** * @type {string} miseryKey - The value of CUTCAPTCHA_MISERY_KEY variable defined on page. */ __publicField(this, "miseryKey"); /** * @type {string} apiKey - The value of data-apikey attribute of iframe's body. Also the name of javascript file included on the page */ __publicField(this, "apiKey"); __publicField(this, "proxyAddress"); __publicField(this, "proxyLogin"); __publicField(this, "proxyPassword"); __publicField(this, "proxyPort"); __publicField(this, "proxyType"); this.miseryKey = miseryKey; this.websiteURL = websiteURL; this.proxyAddress = proxyAddress; this.proxyLogin = proxyLogin; this.proxyPassword = proxyPassword; this.proxyPort = proxyPort; this.proxyType = proxyType; this.apiKey = apiKey; } }; __name(_CutCaptchaTaskBase, "CutCaptchaTaskBase"); var CutCaptchaTaskBase = _CutCaptchaTaskBase; // src/lib/Requests/Token/CutCaptchaTaskProxyless.ts var _CutCaptchaTaskProxyless = class _CutCaptchaTaskProxyless extends CutCaptchaTaskBase { /** * Create CutCaptchaTaskProxyless * @see {@link https://2captcha.com/api-docs/cutcaptcha} * @param {Object} params - CutCaptchaTaskProxylessParams * @param {string} [params.websiteURL] - The full URL of target web page where the captcha is loaded. We do not open the page, not a problem if it is available only for authenticated users * @param {string} [params.miseryKey] - The value of CUTCAPTCHA_MISERY_KEY variable defined on page. * @param {string} [params.apiKey] - The value of data-apikey attribute of iframe's body. Also the name of javascript file included on the page */ constructor(params) { super(params, "CutCaptchaTaskProxyless"); /** * @type {boolean} _isCutCaptchaTask - Only used for correct method overloading intellisense */ __publicField(this, "_isCutCaptchaTaskProxyless", true); } }; __name(_CutCaptchaTaskProxyless, "CutCaptchaTaskProxyless"); var CutCaptchaTaskProxyless = _CutCaptchaTaskProxyless; // src/lib/Requests/Token/CutCaptchaTask.ts var _CutCaptchaTask = class _CutCaptchaTask extends CutCaptchaTaskBase { /** * Create CutCaptchaTask * @see {@link https://2captcha.com/api-docs/cutcaptcha} * @param {Object} params - CutCaptchaTaskParams * @param {string} [params.websiteURL] - The full URL of target web page where the captcha is loaded. We do not open the page, not a problem if it is available only for authenticated users * @param {string} [params.miseryKey] - The value of CUTCAPTCHA_MISERY_KEY variable defined on page. * @param {string} [params.apiKey] - The value of data-apikey attribute of iframe's body. Also the name of javascript file included on the page * @param {string} [params.proxyAddress] - Proxy IP address or hostname * @param {string} [params.proxyLogin] - Login for basic authentication on the proxy * @param {string} [params.proxyPassword] - Password for basic authentication on the proxy * @param {string} [params.proxyType] - Type of your proxy: HTTP, HTTPS, SOCKS4, SOCKS5 * @param {string} [params.proxyPort] - Proxy port */ constructor(params) { super(params, "CutCaptchaTask"); /** * @type {boolean} _isCutCaptchaTask - Only used for correct method overloading intellisense */ __publicField(this, "_isCutCaptchaTask", true); } }; __name(_CutCaptchaTask, "CutCaptchaTask"); var CutCaptchaTask = _CutCaptchaTask; // src/lib/Requests/Token/Base/_TurnstileTaskBase.ts var _TurnstileTaskBase = class _TurnstileTaskBase extends BaseTask { /** * TurnstileTaskBase * @see {@link https://2captcha.com/api-docs/cloudflare-turnstile} * @param {Object} params - TurnstileTaskParams * @param {string} [params.websiteURL] - The full URL of target web page where the captcha is loaded. We do not open the page, not a problem if it is available only for authenticated users * @param {string} [params.websiteKey] - Turnstile sitekey. Can be found inside data-sitekey property of the Turnstile div element * @param {string} [params.actions] - Required for Cloudflare Challenge pages. The value of action parameter of turnstile.render call * @param {string} [params.data] - Required for Cloudflare Challenge pages. The value of cData parameter of turnstile.render call * @param {string} [params.pagedata] - Required for Cloudflare Challenge pages. The value of chlPageData parameter of turnstile.render call * @param {string} [params.proxyAddress] - Proxy IP address or hostname * @param {string} [params.proxyLogin] - Login for basic authentication on the proxy * @param {string} [params.proxyPassword] - Password for basic authentication on the proxy * @param {string} [params.proxyType] - Type of your proxy: HTTP, HTTPS, SOCKS4, SOCKS5 * @param {string} [params.proxyPort] - Proxy port */ constructor({ websiteKey, websiteURL, proxyAddress, proxyPort, proxyType, proxyLogin, proxyPassword, userAgent, pagedata, data, action }, type) { super({ type }); /** * @type {string} websiteURL - The full URL of target web page where the captcha is loaded. We do not open the page, not a problem if it is available only for authenticated users */ __publicField(this, "websiteURL"); /** * @type {string} websiteKey - Turnstile sitekey. Can be found inside data-sitekey property of the Turnstile div element */ __publicField(this, "websiteKey"); /** * @type {string} action - Required for Cloudflare Challenge pages. The value of action parameter of turnstile.render call */ __publicField(this, "action"); /** * @type {string} data - Required for Cloudflare Challenge pages. The value of cData parameter of turnstile.render call */ __publicField(this, "data"); /** * @type {string} pagedata - Required for Cloudflare Challenge pages. The value of chlPageData parameter of turnstile.render call */ __publicField(this, "pagedata"); /** * @type {string} userAgent - User-Agent of your browser will be used to load the captcha. Use only modern browser's User-Agents */ __publicField(this, "userAgent"); __publicField(this, "proxyAddress"); __publicField(this, "proxyLogin"); __publicField(this, "proxyPassword"); __publicField(this, "proxyPort"); __publicField(this, "proxyType"); this.websiteKey = websiteKey; this.websiteURL = websiteURL; this.proxyAddress = proxyAddress; this.proxyLogin = proxyLogin; this.proxyPassword = proxyPassword; this.proxyPort = proxyPort; this.proxyType = proxyType; this.userAgent = userAgent; this.action = action; this.pagedata = pagedata; this.data = data; } }; __name(_TurnstileTaskBase, "TurnstileTaskBase"); var TurnstileTaskBase = _TurnstileTaskBase; // src/lib/Requests/Token/TurnstileTaskProxyless.ts var _TurnstileTaskProxyless = class _TurnstileTaskProxyless extends TurnstileTaskBase { /** * Create TurnstileTaskProxyless * @see {@link https://2captcha.com/api-docs/cloudflare-turnstile} * @param {Object} params - TurnstileTaskProxylessParams * @param {string} [params.websiteURL] - The full URL of target web page where the captcha is loaded. We do not open the page, not a problem if it is available only for authenticated users * @param {string} [params.websiteKey] - Turnstile sitekey. Can be found inside data-sitekey property of the Turnstile div element * @param {string} [params.actions] - Required for Cloudflare Challenge pages. The value of action parameter of turnstile.render call * @param {string} [params.data] - Required for Cloudflare Challenge pages. The value of cData parameter of turnstile.render call * @param {string} [params.pagedata] - Required for Cloudflare Challenge pages. The value of chlPageData parameter of turnstile.render call */ constructor(params) { super(params, "TurnstileTaskProxyless"); /** * @type {boolean} _isTurnstileTaskProxyless - Only used for correct method overloading intellisense */ __publicField(this, "_isTurnstileTaskProxyless", true); } }; __name(_TurnstileTaskProxyless, "TurnstileTaskProxyless"); var TurnstileTaskProxyless = _TurnstileTaskProxyless; // src/lib/Requests/Token/TurnstileTask.ts var _TurnstileTask = class _TurnstileTask extends TurnstileTaskBase { /** * Create TurnstileTask * @see {@link https://2captcha.com/api-docs/cloudflare-turnstile} * @param {Object} params - TurnstileTaskParams * @param {string} [params.websiteURL] - The full URL of target web page where the captcha is loaded. We do not open the page, not a problem if it is available only for authenticated users * @param {string} [params.websiteKey] - Turnstile sitekey. Can be found inside data-sitekey property of the Turnstile div element * @param {string} [params.actions] - Required for Cloudflare Challenge pages. The value of action parameter of turnstile.render call * @param {string} [params.data] - Required for Cloudflare Challenge pages. The value of cData parameter of turnstile.render call * @param {string} [params.pagedata] - Required for Cloudflare Challenge pages. The value of chlPageData parameter of turnstile.render call * @param {string} [params.proxyAddress] - Proxy IP address or hostname * @param {string} [params.proxyLogin] - Login for basic authentication on the proxy * @param {string} [params.proxyPassword] - Password for basic authentication on the proxy * @param {string} [params.proxyType] - Type of your proxy: HTTP, HTTPS, SOCKS4, SOCKS5 * @param {string} [params.proxyPort] - Proxy port */ constructor(params) { super(params, "TurnstileTask"); /** * @type {boolean} _isTurnstileTask - Only used for correct method overloading intellisense */ __publicField(this, "_isTurnstileTask", true); } }; __name(_TurnstileTask, "TurnstileTask"); var TurnstileTask = _TurnstileTask; // src/lib/Requests/Token/Base/_RecaptchaV2TaskBase.ts var _RecaptchaV2TaskBase = class _RecaptchaV2TaskBase extends BaseTask { /** * RecaptchaV2TaskBase * @see {@link https://2captcha.com/api-docs/recaptcha-v2} * @param {Object} params - RecaptchaV2TaskBaseParams * @param {string} [params.websiteURL] - The full URL of target web page where the captcha is loaded. We do not open the page, not a problem if it is available only for authenticated users * @param {string} [params.websiteKey] - reCAPTCHA sitekey. Can be found inside data-sitekey property of the reCAPTCHA div element or inside k parameter of the requests to reCAPTHCHA API. You can also use the script to find the value * @param {string} [params.userAgent] - User-Agent of your browser will be used to load the captcha. Use only modern browser's User-Agents * @param {boolean}[params.isInvisible] - Pass true for Invisible version of reCAPTCHA - a case when you don't see the checkbox, but the challenge appears. Mostly used with a callback function * @param {string} [params.recaptchaDataSValue] - The value of data-s parameter. Can be required to bypass the captcha on Google services * @param {string} [params.apiDomain] - Domain used to load the captcha: google.com or recaptcha.net. Default value: google.com * @param {string} [params.co