UNPKG

@captcha-libs/capsolver

Version:

CapSolver NodeJS client, captcha recognition service

1,126 lines (1,102 loc) 120 kB
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }var __defProp = Object.defineProperty; 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 __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/capsolver.ts var _nodefetch = require('node-fetch'); var _nodefetch2 = _interopRequireDefault(_nodefetch); var _CapSolver = class _CapSolver 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.capsolver.com"); __publicField(this, "appId", "123FB4BE-4028-4B49-A71B-D6D578F88136"); 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(); if ("errorCode" in response && !("balance" in response)) throw new Error(`CapSolver: ${response.errorCode}`); return response; }); } /** * @param {object} request - task payload to create task * @return {Promise<CapSolverCreateTaskResponse<TSolution>>} - response of createTask */ createTask(request) { return __async(this, null, function* () { const _a = request, { _endpoint } = _a, task = __objRest(_a, ["_endpoint"]); const body = yield _nodefetch2.default.call(void 0, `${this.baseUrl}/${_endpoint}`, { "body": JSON.stringify({ "appId": this.appId, "clientKey": this.clientKey, "task": task }), "headers": { "Content-Type": "application/json" }, "method": "POST" }); const response = yield body.json(); if (response.errorCode) throw new Error(`CapSolver: ${response.errorCode}`); return response; }); } /** * We rely on reports to automatically analyze the quality of tokens issued by our API. These reports are processed automatically, and our team takes proactive steps to enhance token quality, such as updating the system for new tasks, improving grids, and more. * @see {@link https://docs.capsolver.com/guide/api-feedback.html} * @param {FeedbackTaskParams} params - task feedback payload * @param {string} [params.taskId] - Your task id * @param {boolean} [params.invalid] - is task result invalid? * @param {number} [params.code] - code of task result * @param {number} [params.message] - invalid token messages */ feedbackTask(params) { return __async(this, null, function* () { const _a = params, { taskId } = _a, result = __objRest(_a, ["taskId"]); const body = yield _nodefetch2.default.call(void 0, `${this.baseUrl}/feedbackTask`, { "body": JSON.stringify({ "appId": this.appId, "clientKey": this.clientKey, result, taskId }), "headers": { "Content-Type": "application/json" }, "method": "POST" }); const response = yield body.json(); return response; }); } /** * @param {Requests} request - task payload to create task * @return {Promise<CapSolverSolution<TSolution>>} - response of createTask */ solve(request) { return __async(this, null, function* () { const balance = yield this.getBalance(); if (!balance) throw new Error("CapSolver: ERROR_ZERO_BALANCE"); const _a = __spreadValues({ "_isAntiAkamaiBMPTask": false, "_isAntiAkamaiPowTask": false, "_isAntiAkamaiSensorTask": false, "_isAntiAkamaiWebTask": false, "_isAntiAwsWafTask": false, "_isAntiAwsWafTaskProxyLess": false, "_isAntiCloudflareChallengeTask": false, "_isAntiCloudflareTurnstileTask": false, "_isAntiCyberSiAraTask": false, "_isAntiCyberSiAraTaskProxyLess": false, "_isAntiImpervaTask": false, "_isAntiImpervaTaskProxyLess": false, "_isAwsWafClassification": false, "_isBaseTask": false, "_isDataDomeSliderTask": false, "_isFunCaptchaClassification": false, "_isFunCaptchaTaskProxyLess": false, "_isGeeTestTask": false, "_isGeeTestTaskProxyLess": false, "_isGeeTestV3Task": false, "_isGeeTestV3TaskProxyLess": false, "_isGeeTestV4Task": false, "_isGeeTestV4TaskProxyLess": false, "_isHCaptchaClassification": false, "_isHCaptchaTask": false, "_isHCaptchaTaskProxyLess": false, "_isImageToTextTask": false, "_isMtCaptchaTask": false, "_isMtCaptchaTaskProxyLess": false, "_isReCaptchaV2Classification": false, "_isReCaptchaV2EnterpriseTask": false, "_isReCaptchaV2EnterpriseTaskProxyLess": false, "_isReCaptchaV2Task": false, "_isReCaptchaV2TaskProxyLess": false, "_isReCaptchaV3EnterpriseTask": false, "_isReCaptchaV3EnterpriseTaskProxyLess": false, "_isReCaptchaV3M1TaskProxyLess": false, "_isReCaptchaV3Task": false, "_isReCaptchaV3TaskProxyLess": false, "_isVisionEngine": false, "_isFunCaptchaTask": false, "_isAntiTurnstileTaskProxyLess": false }, request), { _isAntiAkamaiBMPTask = false, _isAntiAkamaiPowTask = false, _isAntiAkamaiSensorTask = false, _isAntiAkamaiWebTask = false, _isAntiAwsWafTask = false, _isAntiAwsWafTaskProxyLess = false, _isAntiCloudflareChallengeTask = false, _isAntiCloudflareTurnstileTask = false, _isAntiCyberSiAraTask = false, _isAntiCyberSiAraTaskProxyLess = false, _isAntiImpervaTask = false, _isAntiImpervaTaskProxyLess = false, _isAwsWafClassification = false, _isBaseTask = false, _isDataDomeSliderTask = false, _isFunCaptchaClassification = false, _isFunCaptchaTaskProxyLess = false, _isGeeTestTask = false, _isGeeTestTaskProxyLess = false, _isGeeTestV3Task = false, _isGeeTestV3TaskProxyLess = false, _isGeeTestV4Task = false, _isGeeTestV4TaskProxyLess = false, _isHCaptchaClassification = false, _isHCaptchaTask = false, _isHCaptchaTaskProxyLess = false, _isImageToTextTask = false, _isMtCaptchaTask = false, _isMtCaptchaTaskProxyLess = false, _isReCaptchaV2Classification = false, _isReCaptchaV2EnterpriseTask = false, _isReCaptchaV2EnterpriseTaskProxyLess = false, _isReCaptchaV2Task = false, _isReCaptchaV2TaskProxyLess = false, _isReCaptchaV3EnterpriseTask = false, _isReCaptchaV3EnterpriseTaskProxyLess = false, _isReCaptchaV3M1TaskProxyLess = false, _isReCaptchaV3Task = false, _isReCaptchaV3TaskProxyLess = false, _isVisionEngine = false, _isFunCaptchaTask = false, _isAntiTurnstileTaskProxyLess = false } = _a, payload = __objRest(_a, ["_isAntiAkamaiBMPTask", "_isAntiAkamaiPowTask", "_isAntiAkamaiSensorTask", "_isAntiAkamaiWebTask", "_isAntiAwsWafTask", "_isAntiAwsWafTaskProxyLess", "_isAntiCloudflareChallengeTask", "_isAntiCloudflareTurnstileTask", "_isAntiCyberSiAraTask", "_isAntiCyberSiAraTaskProxyLess", "_isAntiImpervaTask", "_isAntiImpervaTaskProxyLess", "_isAwsWafClassification", "_isBaseTask", "_isDataDomeSliderTask", "_isFunCaptchaClassification", "_isFunCaptchaTaskProxyLess", "_isGeeTestTask", "_isGeeTestTaskProxyLess", "_isGeeTestV3Task", "_isGeeTestV3TaskProxyLess", "_isGeeTestV4Task", "_isGeeTestV4TaskProxyLess", "_isHCaptchaClassification", "_isHCaptchaTask", "_isHCaptchaTaskProxyLess", "_isImageToTextTask", "_isMtCaptchaTask", "_isMtCaptchaTaskProxyLess", "_isReCaptchaV2Classification", "_isReCaptchaV2EnterpriseTask", "_isReCaptchaV2EnterpriseTaskProxyLess", "_isReCaptchaV2Task", "_isReCaptchaV2TaskProxyLess", "_isReCaptchaV3EnterpriseTask", "_isReCaptchaV3EnterpriseTaskProxyLess", "_isReCaptchaV3M1TaskProxyLess", "_isReCaptchaV3Task", "_isReCaptchaV3TaskProxyLess", "_isVisionEngine", "_isFunCaptchaTask", "_isAntiTurnstileTaskProxyLess"]); const createTaskResponse = yield this.createTask(payload); if (createTaskResponse.solution) return createTaskResponse; 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({ "taskId": createTaskResponse.taskId }), "method": "POST", "headers": { "Content-Type": "application/json" }, "signal": abortSignal }); const response = yield body.json(); if (response.solution) return response; else if (response.errorCode) throw new Error(`CapSolver: ${response.errorDescription}`); yield delay(this.pollingInterval); } } catch (error) { if (error instanceof _nodefetch.AbortError && error.name === "AbortError") throw new Error(`CapSolver timeout ${this.timeout} exceeded!`); else throw error; } throw new Error("CapSolver finished with error"); }); } }; __name(_CapSolver, "CapSolver"); var CapSolver = _CapSolver; // src/lib/Requests/_BaseTaskRequest.ts var _BaseTask = class _BaseTask { constructor(params) { /** * @type {TaskTypes} type - task type */ __publicField(this, "type"); /** * @type {string} _endpoint - special endpoint for task request */ __publicField(this, "_endpoint", "createTask"); const { type, _endpoint = "createTask" } = params || { "_endpoint": "createTask" }; this.type = type; this._endpoint = _endpoint; } }; __name(_BaseTask, "BaseTask"); var BaseTask = _BaseTask; // src/lib/Requests/Classification/AwsWafClassification.ts var _AwsWafClassification = class _AwsWafClassification extends BaseTask { /** * Create AwsWafClassification * @see {@link https://docs.capsolver.com/guide/recognition/AwsWafClassification.html} * @param {object} params - AwsWafClassificationParams * @param {string} [params.question] - For full names of questions, please refer to the following list of questions. * @param {string[]} [params.images] - base64 image string * @param {string=} [params.websiteKey] - Website key to improve accuracy * @param {string=} [params.websiteURL] - Page source url to improve accuracy */ constructor({ websiteKey, question, websiteURL, images }) { super({ "type": "AwsWafClassification" }); /** * @type {boolean} _isAwsWafClassification - Only used for correct method overloading intellisense */ __publicField(this, "_isAwsWafClassification", true); /** * @type {string} question - For full names of questions, please refer to the following list of questions. */ __publicField(this, "question"); /** * @type {string[]} images - base64 image string */ __publicField(this, "images"); /** * @type {string=} websiteKey - Website key to improve accuracy */ __publicField(this, "websiteKey"); /** * * @type {string=} websiteURL - Page source url to improve accuracy */ __publicField(this, "websiteURL"); this.images = images; this.websiteKey = websiteKey; this.websiteURL = websiteURL; this.question = question; } }; __name(_AwsWafClassification, "AwsWafClassification"); var AwsWafClassification = _AwsWafClassification; // src/lib/Requests/Classification/FunCaptchaClassification.ts var _FunCaptchaClassification = class _FunCaptchaClassification extends BaseTask { /** * Create FunCaptchaClassification * @see {@link https://docs.capsolver.com/guide/recognition/FunCaptchaClassification.html} * @param {Object} params - ImageToTextParams * @param {string} [params.question] - Question name. this param value from API response game_variant field. Exmaple: maze,maze2,flockCompass,3d_rollball_animals * @param {string} [params.images] - Base64 encoded image, can be a screenshot (pass only the hexagonal image, do not pass the rest of the content) * @param {string} [params.module] - module name {@see https://docs.capsolver.com/guide/recognition/FunCaptchaClassification.html} * @param {string} [params.websiteURL] - Page source url to improve accuracy * @param {string} [params.websiteKey] - Website key to improve accuracy */ constructor({ images, module, question, websiteKey, websiteURL }) { super({ "type": "FunCaptchaClassification" }); /** * @type {boolean} _isFunCaptchaClassification - Only used for correct method overloading intellisense */ __publicField(this, "_isFunCaptchaClassification", true); /** * @type {string} question - Question name. this param value from API response game_variant field. Exmaple: maze,maze2,flockCompass,3d_rollball_animals */ __publicField(this, "question"); /** * @type {string} images - Base64 encoded image, can be a screenshot (pass only the hexagonal image, do not pass the rest of the content) */ __publicField(this, "images"); /** * @type {string} module - module name * @see {@link https://docs.capsolver.com/guide/recognition/FunCaptchaClassification.html} */ __publicField(this, "module"); /** * @type {string} websiteURL - Page source url to improve accuracy */ __publicField(this, "websiteURL"); /** * @type {string} websiteKey - Website key to improve accuracy */ __publicField(this, "websiteKey"); this.images = images; this.module = module; this.question = question; this.websiteKey = websiteKey; this.websiteURL = websiteURL; } }; __name(_FunCaptchaClassification, "FunCaptchaClassification"); var FunCaptchaClassification = _FunCaptchaClassification; // src/lib/Requests/Classification/HCaptchaClassification.ts var _HCaptchaClassification = class _HCaptchaClassification extends BaseTask { /** * Create HCaptchaClassification * @see {@link https://docs.capsolver.com/guide/recognition/HCaptchaClassification.html} * @param {Object} params - ImageToTextParams * @param {string} [params.question] - English is supported only. Please convert other languages by yourself * @param {string} [params.queries] - Base64 encoded image, do not include "data:image/***; base64," Assembles the picture as a list: [base64,base64,base64...] * @param {string} [params.websiteKey] - Website key to improve accuracy * @param {string} [params.websiteURL] - Page source url to improve accuracy */ constructor({ queries, question, websiteKey, websiteURL }) { super({ "type": "HCaptchaClassification" }); /** * @type {boolean} _isHCaptchaClassification - Only used for correct method overloading intellisense */ __publicField(this, "_isHCaptchaClassification", true); /** * @type {string} question - English is supported only. Please convert other languages by yourself */ __publicField(this, "question"); // // @type {string} queries - Base64 encoded image, do not include "data:image/***; base64," // Assembles the picture as a list: [base64,base64,base64...] // __publicField(this, "queries"); /** * @type {string} websiteKey - Website key to improve accuracy */ __publicField(this, "websiteKey"); /** * @type {string} websiteURL - Page source url to improve accuracy */ __publicField(this, "websiteURL"); this.queries = queries; this.question = question; this.websiteURL = websiteURL; this.websiteKey = websiteKey; } }; __name(_HCaptchaClassification, "HCaptchaClassification"); var HCaptchaClassification = _HCaptchaClassification; // src/lib/Requests/Classification/ImageToTextTask.ts var _ImageToTextTask = class _ImageToTextTask extends BaseTask { /** * Create ImageToTextTask * @see {@link https://docs.capsolver.com/guide/recognition/ImageToTextTask.html} * @param {Object} params - ImageToTextParams * @param {string} [params.body] - base64 encoded content of the image (no newlines) (no data:image/*; base64, content * @param {boolean=} [params.isCaseSensitive] - Case sensitive or not * @param {ImageToTextModules=} [params.module] - Specifies the module. Currently, the supported modules are common and queueit * @param {number=} [params.score] - 0.8 ~ 1, Identify the matching degree. If the recognition rate is not within the range, no deduction * @param {string} [params.websiteURL] - Page source url to improve accuracy */ constructor({ body, "module": _module, score, websiteURL }) { super({ "type": "ImageToTextTask" }); /** * @type {boolean} _isImageToTextTask - Only used for correct method overloading intellisense */ __publicField(this, "_isImageToTextTask", true); /** * @type {string} body - base64 encoded content of the image (no newlines) (no data:image/*; base64, content */ __publicField(this, "body"); /** * @type {boolean=} case - Case sensitive or not */ __publicField(this, "case"); /** * @type {ImageToTextModules=} module - Specifies the module. Currently, the supported modules are common and queueit * {@see https://docs.capsolver.com/guide/recognition/ImageToTextTask.html} */ __publicField(this, "module"); /** * @type {number=} score - 0.8 ~ 1, Identify the matching degree. If the recognition rate is not within the range, no deduction */ __publicField(this, "score"); /** * @type {string} websiteURL - Page source url to improve accuracy */ __publicField(this, "websiteURL"); this.body = body; this.score = score; this.module = _module; this.websiteURL = websiteURL; } }; __name(_ImageToTextTask, "ImageToTextTask"); var ImageToTextTask = _ImageToTextTask; // src/lib/Requests/Classification/ReCaptchaV2Classification.ts var _ReCaptchaV2Classification = class _ReCaptchaV2Classification extends BaseTask { /** * Create ReCaptchaV2Classification * @see {@link https://docs.capsolver.com/guide/recognition/ReCaptchaClassification.html} * @param {Object} params - ReCaptchaClassificationParams * @param {string} [params.question] - please refer to the following list of questions. * @param {string} [params.image] - base64 image string * @param {string=} [params.websiteKey] - Website key to improve accuracy * @param {string=} [params.websiteURL] - Page source url to improve accuracy */ constructor({ websiteKey, question, websiteURL, image }) { super({ "type": "ReCaptchaV2Classification" }); /** * @type {boolean} _isReCaptchaV2Classification - Only used for correct method overloading intellisense */ __publicField(this, "_isReCaptchaV2Classification", true); /** * @type {string} question - please refer to the following list of questions. * @see {@link https://docs.capsolver.com/guide/recognition/ReCaptchaClassification.html} */ __publicField(this, "question"); /** * @type {string} image - base64 image string */ __publicField(this, "image"); /** * @type {string=} websiteKey - Website key to improve accuracy */ __publicField(this, "websiteKey"); /** * @type {string=} websiteURL - Page source url to improve accuracy */ __publicField(this, "websiteURL"); this.image = image; this.websiteKey = websiteKey; this.websiteURL = websiteURL; this.question = question; } }; __name(_ReCaptchaV2Classification, "ReCaptchaV2Classification"); var ReCaptchaV2Classification = _ReCaptchaV2Classification; // src/lib/Requests/Classification/VisionEngine.ts var _VisionEngine = class _VisionEngine extends BaseTask { /** * Create VisionEngine * @see {@link https://docs.capsolver.com/guide/recognition/VisionEngine.html} * @param {Object} params - VisionEngineParams * @param {string} [params.image] - base64 encoded content of the image (no newlines, no data:image/***;charset=utf-8;base64,) * @param {string} [params.imageBackground] - base64 encoded content of the image (no newlines, no data:image/***;charset=utf-8;base64,) * @param {string} [params.question] - required for "space_detection" module * @param {VisionEngineModules=} [params.module] - Specifies the module. * @param {string} [params.websiteURL] - Page source url to improve accuracy */ constructor({ image, imageBackground, question, module, websiteURL }) { super({ "type": "VisionEngine" }); /** * @type {boolean} _isVisionEngine - Only used for correct method overloading intellisense */ __publicField(this, "_isVisionEngine", true); /** * @type {string} image - base64 encoded content of the image (no newlines, no data:image/***;charset=utf-8;base64,) */ __publicField(this, "image"); /** * @type {string} image - base64 encoded content of the image (no newlines, no data:image/***;charset=utf-8;base64,) */ __publicField(this, "imageBackground"); /** * @type {VisionEngineModules=} module - Specifies the module * {@see https://docs.capsolver.com/guide/recognition/VisionEngine.html} */ __publicField(this, "module"); /** * @param {string} question - required for "space_detection" module */ __publicField(this, "question"); /** * @type {string} websiteURL - Page source url to improve accuracy */ __publicField(this, "websiteURL"); this.image = image; this.imageBackground = imageBackground; this.question = question; this.module = module; this.websiteURL = websiteURL; } }; __name(_VisionEngine, "VisionEngine"); var VisionEngine = _VisionEngine; // src/lib/Requests/Token/AntiAkamaiBMPTask.ts var _AntiAkamaiBMPTask = class _AntiAkamaiBMPTask extends BaseTask { /** * Create AntiAkamaiBMPTaskBase * @see {@link https://docs.capsolver.com/guide/antibots/akamaibmp.html} * @param {object} params - AntiAkamaiBMPTaskBaseParams * @param {number} [params.count] - Sensor combinations acquired at once, 0< count <= 50, max 50 items acquired at once * @param {string} [params.deviceId] - If you want to have a fixed device ID in the sensor, you can pass this parameter * @param {string} [params.deviceName] - Input fixed deviceInfo,default is: random. example: iPhone14,2/16.0.2 * @param {string} [params.packageName] - Package name of AkamaiBMP mobile APP, de.package.iphone * @param {string} [params.pow] - Support: /_bm/get_params data. If this parameter is passed in, the other parameters will be ignored to generate the pow string * @param {string} [params.version] - AKAMAI BMP Version number, default is: 3.2.6 , max support 3.3.1 */ constructor({ count, deviceId, deviceName, packageName, pow, version, metadata, country }) { super({ "_endpoint": "akamaibmp/invoke", "type": "AntiAkamaiBMPTask" }); /** * @type {boolean} _isAntiAkamaiBMPTask - Only used for correct method overloading intellisense */ __publicField(this, "_isAntiAkamaiBMPTask", true); /** * @type {number} count - Sensor combinations acquired at once, 0< count <= 50, max 50 items acquired at once */ __publicField(this, "count"); /** * @type {string} deviceId - If you want to have a fixed device ID in the sensor, you can pass this parameter */ __publicField(this, "deviceId"); /** * @type {string} deviceName - Input fixed deviceInfo,default is: random. example: iPhone14,2/16.0.2 */ __publicField(this, "deviceName"); /** * @type {string} packageName - Package name of AkamaiBMP mobile APP, de.package.iphone */ __publicField(this, "packageName"); // // @type {string} pow - Support: /_bm/get_params data // {"mode":1,"nonce":"3764bd11365749ec62974f920eb3614c","ttl":21600,"difficulty":6000,"timeout":100,"n":490,"s_timeout":100,"checksum":"plKZ9lBBJwLeeWRjoaZ4OevBFoPf3EyJIFgp2utWwI3ly34OsW6JluR2nY+lAwapZAcMf/kCo2g5ni6daXPhBSpg=="} If this parameter is passed in, the other parameters will be ignored to generate the pow string // __publicField(this, "pow"); /** * @type {string} version - AKAMAI BMP Version number, default is: 3.2.6 , max support 3.3.1 */ __publicField(this, "version"); /** * @type {object} metadata - Use for sensor task */ __publicField(this, "metadata"); /** * @type {string} country - */ __publicField(this, "country"); this.count = count; this.deviceId = deviceId; this.deviceName = deviceName; this.packageName = packageName; this.pow = pow; this.version = version; this.metadata = metadata; this.country = country; } }; __name(_AntiAkamaiBMPTask, "AntiAkamaiBMPTask"); var AntiAkamaiBMPTask = _AntiAkamaiBMPTask; // src/lib/Requests/Token/AntiAkamaiPowTask.ts var _AntiAkamaiPowTask = class _AntiAkamaiPowTask extends BaseTask { /** * Create AntiAkamaiPowTask * @see {@link https://docs.capsolver.com/guide/antibots/akamaibmp.html} * @param {object} params - AntiAkamaiPowTaskParams * @param {string} [params.deviceId] - If you want to have a fixed device ID in the sensor, you can pass this parameter * @param {string} [params.pow] - Support: /_bm/get_params data. If this parameter is passed in, the other parameters will be ignored to generate the pow string */ constructor({ deviceId, pow }) { super({ "_endpoint": "akamaibmp/invoke", "type": "AntiAkamaiBMPTask" }); /** * @type {boolean} _isAntiAkamaiBMPTask - Only used for correct method overloading intellisense */ __publicField(this, "_isAntiAkamaiBMPTask", true); /** * @type {string} deviceName - Input fixed deviceInfo,default is: random. example: iPhone14,2/16.0.2 */ __publicField(this, "deviceId"); // // @type {string} pow - Support: /_bm/get_params data // {"mode":1,"nonce":"3764bd11365749ec62974f920eb3614c","ttl":21600,"difficulty":6000,"timeout":100,"n":490,"s_timeout":100,"checksum":"plKZ9lBBJwLeeWRjoaZ4OevBFoPf3EyJIFgp2utWwI3ly34OsW6JluR2nY+lAwapZAcMf/kCo2g5ni6daXPhBSpg=="} If this parameter is passed in, the other parameters will be ignored to generate the pow string // __publicField(this, "pow"); this.deviceId = deviceId; this.pow = pow; } }; __name(_AntiAkamaiPowTask, "AntiAkamaiPowTask"); var AntiAkamaiPowTask = _AntiAkamaiPowTask; // src/lib/Requests/Token/AntiAkamaiSensorTask.ts var _AntiAkamaiSensorTask = class _AntiAkamaiSensorTask extends BaseTask { /** * Create AntiAkamaiSensorTask * This task type uses a separate endpoint for fetching /akamaibmp/invoke * @see {@link https://docs.capsolver.com/guide/antibots/akamaibmp.html} * @param {object} params - AntiAkamaiSensorTaskParams * @param {string} [params.packageName] - required. Package name of AkamaiBMP mobile APP, de.package.iphone * @param {string} [params.version] - required. AKAMAI BMP Version number, default is: 3.2.6 , max support 3.3.1 * @param {number} [params.count] - Sensor combinations acquired at once, 0< count <= 50, max 50 items acquired at once * @param {string} [params.deviceId] - If you want to have a fixed device ID in the sensor, you can pass this parameter * @param {string} [params.deviceName] - Input fixed deviceInfo,default is: random. example: iPhone14,2/16.0.2 */ constructor({ count, country, deviceId, deviceName, metadata, packageName, version }) { super({ "_endpoint": "akamaibmp/invoke", "type": "AntiAkamaiBMPTask" }); /** * @type {boolean} _isAntiAkamaiBMPTask - Only used for correct method overloading intellisense */ __publicField(this, "_isAntiAkamaiBMPTask", true); /** * @type {number} count - Sensor combinations acquired at once, 0< count <= 50, max 50 items acquired at once */ __publicField(this, "count"); /** * @type {string} country - */ __publicField(this, "country"); /** * @type {string} deviceId - If you want to have a fixed device ID in the sensor, you can pass this parameter */ __publicField(this, "deviceId"); /** * @type {string} deviceName - Input fixed deviceInfo,default is: random. example: iPhone14,2/16.0.2 */ __publicField(this, "deviceName"); /** * @type {object} metadata - Use for sensor task */ __publicField(this, "metadata"); /** * @type {string} packageName - Package name of AkamaiBMP mobile APP, de.package.iphone */ __publicField(this, "packageName"); /** * @type {string} version - AKAMAI BMP Version number, default is: 3.2.6 , max support 3.3.1 */ __publicField(this, "version"); this.count = count; this.country = country; this.deviceId = deviceId; this.deviceName = deviceName; this.metadata = metadata; this.packageName = packageName; this.version = version; } }; __name(_AntiAkamaiSensorTask, "AntiAkamaiSensorTask"); var AntiAkamaiSensorTask = _AntiAkamaiSensorTask; // src/lib/Requests/Token/AntiAkamaiWebTask.ts var _AntiAkamaiWebTask = class _AntiAkamaiWebTask extends BaseTask { /** * Create AntiAkamaiWebTaskBase * @see {@link https://docs.capsolver.com/guide/antibots/akamaibmp.html} * @param {object} params - AntiAkamaiWebTaskBaseParams * @param {string} [params.url] - browser url address * @param {string} [params.abck] - akamai cookie * @param {string} [params.userAgent] - The browser's request header ua */ constructor({ abck, bmsz, url, userAgent }) { super({ "_endpoint": "akamaiweb/invoke", "type": "AntiAkamaiWebTask" }); /** * @type {boolean} _isAntiAkamaiWebTask - Only used for correct method overloading intellisense */ __publicField(this, "_isAntiAkamaiWebTask", true); /** * @type {string} url - browser url address */ __publicField(this, "url"); /** * @type {string} abck - akamai cookie */ __publicField(this, "abck"); /** * @type {string} bmsz - akamai cookie */ __publicField(this, "bmsz"); /** * @type {string} userAgent - The browser's request header ua */ __publicField(this, "userAgent"); this.abck = abck; this.bmsz = bmsz; this.url = url; this.userAgent = userAgent; } }; __name(_AntiAkamaiWebTask, "AntiAkamaiWebTask"); var AntiAkamaiWebTask = _AntiAkamaiWebTask; // src/lib/Requests/Token/Base/_AntiAwsWafBase.ts var _AntiAwsWafTaskBase = class _AntiAwsWafTaskBase extends BaseTask { // // Create AntiAwsWafTaskBase // {@link https://docs.capsolver.com/guide/captcha/awsWaf.html} // @param {Object} params - AntiAwsWafTaskBaseParams // @param {string=} [params.awsChallengeJS] - When the status code returned by the websiteURL page is 202, you only need to pass in awsChallengeJs; // @param {string=} [params.awsContext] - When the status code returned by the websiteURL page is 405, you need to pass in awsContext // @param {string=} [params.awsIv] - When the status code returned by the websiteURL page is 405, you need to pass in awsIv // @param {string=} [params.awsKey] - When the status code returned by the websiteURL page is 405, you need to pass in awsKey // @param {string} [params.websiteURL] - The URL of the page that returns the captcha info // @param {string} [params.proxy] - proxy // @param {string} [params.proxyAddress] - proxyAddress // @param {string} [params.proxyLogin] - proxyLogin // @param {string} [params.proxyPassword] - proxyPassword // @param {string} [params.proxyPort] - proxyPort // @param {string} [params.proxyType] - proxyType // // constructor({ awsChallengeJS, awsContext, awsIv, awsKey, proxy, websiteURL, proxyAddress, proxyPort, proxyType, proxyLogin, proxyPassword }, type) { super({ type }); __publicField(this, "proxyAddress"); __publicField(this, "proxyLogin"); __publicField(this, "proxyPassword"); __publicField(this, "proxyPort"); __publicField(this, "proxyType"); /** * @type {string=} awsChallengeJS - When the status code returned by the websiteURL page is 202, you only need to pass in awsChallengeJs; */ __publicField(this, "awsChallengeJS"); /** * @type {string=} awsContext - When the status code returned by the websiteURL page is 405, you need to pass in awsContext */ __publicField(this, "awsContext"); /** * @type {string=} awsIv - When the status code returned by the websiteURL page is 405, you need to pass in awsIv */ __publicField(this, "awsIv"); /** * @type {string=} awsKey - When the status code returned by the websiteURL page is 405, you need to pass in awsKey */ __publicField(this, "awsKey"); /** * @type {string=} proxy - proxy */ __publicField(this, "proxy"); /** * @type {string} websiteURL - The URL of the page that returns the captcha info */ __publicField(this, "websiteURL"); this.awsChallengeJS = awsChallengeJS; this.awsContext = awsContext; this.awsIv = awsIv; this.awsKey = awsKey; this.websiteURL = websiteURL; this.proxy = proxy; this.proxyAddress = proxyAddress; this.proxyLogin = proxyLogin; this.proxyPort = proxyPort; this.proxyType = proxyType; this.proxyPassword = proxyPassword; } }; __name(_AntiAwsWafTaskBase, "AntiAwsWafTaskBase"); var AntiAwsWafTaskBase = _AntiAwsWafTaskBase; // src/lib/Requests/Token/AntiAwsWafTask.ts var _AntiAwsWafTask = class _AntiAwsWafTask extends AntiAwsWafTaskBase { /** * Create AntiAwsWafTask - this task type require your own proxies. * @see {@link https://docs.capsolver.com/guide/captcha/awsWaf.html} * @param {Object} params - AntiAwsWafTaskParams * @param {string=} [params.awsChallengeJS] - When the status code returned by the websiteURL page is 202, you only need to pass in awsChallengeJs; * @param {string=} [params.awsContext] - When the status code returned by the websiteURL page is 405, you need to pass in awsContext * @param {string=} [params.awsIv] - When the status code returned by the websiteURL page is 405, you need to pass in awsIv * @param {string=} [params.awsKey] - When the status code returned by the websiteURL page is 405, you need to pass in awsKey * @param {string} [params.proxy] - proxy * @param {string} [params.proxyAddress] - proxyAddress * @param {string} [params.proxyLogin] - proxyLogin * @param {string} [params.proxyPassword] - proxyPassword * @param {string} [params.proxyPort] - proxyPort * @param {string} [params.proxyType] - proxyType * @param {string} [params.websiteURL] - The URL of the page that returns the captcha info */ constructor(params) { super(params, "AntiAwsWafTask"); /** * @type {boolean} _isAntiAwsWafTask - Only used for correct method overloading intellisense */ __publicField(this, "_isAntiAwsWafTask", true); } }; __name(_AntiAwsWafTask, "AntiAwsWafTask"); var AntiAwsWafTask = _AntiAwsWafTask; // src/lib/Requests/Token/AntiAwsWafTaskProxyLess.ts var _AntiAwsWafTaskProxyLess = class _AntiAwsWafTaskProxyLess extends AntiAwsWafTaskBase { /** * Create AntiAwsWafTask * @see {@link https://docs.capsolver.com/guide/captcha/awsWaf.html} * @param {Object} params - AntiAwsWafTaskProxyLessParams * @param {string=} [params.awsChallengeJS] - When the status code returned by the websiteURL page is 202, you only need to pass in awsChallengeJs; * @param {string=} [params.awsContext] - When the status code returned by the websiteURL page is 405, you need to pass in awsContext * @param {string=} [params.awsIv] - When the status code returned by the websiteURL page is 405, you need to pass in awsIv * @param {string=} [params.awsKey] - When the status code returned by the websiteURL page is 405, you need to pass in awsKey * @param {string} [params.websiteURL] - The URL of the page that returns the captcha info */ constructor(params) { super(params, "AntiAwsWafTaskProxyLess"); /** * @type {boolean} _isAntiAwsWafTaskProxyLess - Only used for correct method overloading intellisense */ __publicField(this, "_isAntiAwsWafTaskProxyLess", true); } }; __name(_AntiAwsWafTaskProxyLess, "AntiAwsWafTaskProxyLess"); var AntiAwsWafTaskProxyLess = _AntiAwsWafTaskProxyLess; // src/lib/Requests/Token/Base/_AntiCloudflareBase.ts var _AntiCloudflareTaskBase = class _AntiCloudflareTaskBase extends BaseTask { /** * Create AntiCloudflareTask * @see {@link https://docs.capsolver.com/guide/antibots/cloudflare_challenge.html} * @param {object} params - AntiCloudflareTaskParams * @param {string} [params.websiteURL] - The address of the target page. * @param {string} [params.proxy] - proxy * @param {string} [params.proxyAddress] - proxyAddress * @param {string} [params.proxyLogin] - proxyLogin * @param {string} [params.proxyPassword] - proxyPassword * @param {number} [params.proxyPort] - proxyPort * @param {string} [params.proxyType] - proxyType */ constructor({ websiteURL, proxy, proxyAddress, proxyPort, proxyType, proxyLogin, proxyPassword }, type) { super({ type }); /** * @type {string} proxy - proxy */ __publicField(this, "proxy"); /** * @type {string} websiteURL - The address of the target page. */ __publicField(this, "websiteURL"); __publicField(this, "proxyAddress"); __publicField(this, "proxyLogin"); __publicField(this, "proxyPassword"); __publicField(this, "proxyPort"); __publicField(this, "proxyType"); this.websiteURL = websiteURL; this.proxy = proxy; this.proxyAddress = proxyAddress; this.proxyLogin = proxyLogin; this.proxyPort = proxyPort; this.proxyType = proxyType; this.proxyPassword = proxyPassword; } }; __name(_AntiCloudflareTaskBase, "AntiCloudflareTaskBase"); var AntiCloudflareTaskBase = _AntiCloudflareTaskBase; // src/lib/Requests/Token/AntiCloudflareChallengeTask.ts var _AntiCloudflareChallengeTask = class _AntiCloudflareChallengeTask extends AntiCloudflareTaskBase { /** * Create AntiCloudflareChallengeTask * @see {@link https://docs.capsolver.com/guide/antibots/cloudflare_challenge.html} * @param {object} params - AntiCloudflareChallengeTaskParams * @param {string} [params.proxy] - proxy * @param {string} [params.proxyAddress] - proxyAddress * @param {string} [params.proxyLogin] - proxyLogin * @param {string} [params.proxyPassword] - proxyPassword * @param {number} [params.proxyPort] - proxyPort * @param {string} [params.proxyType] - proxyType * @param {string} [params.websiteURL] - The address of the target page. */ constructor(params) { super(params, "AntiCloudflareTask"); /** * @type {boolean} _isAntiCloudflareTask - Only used for correct method overloading intellisense */ __publicField(this, "_isAntiCloudflareTask", true); } }; __name(_AntiCloudflareChallengeTask, "AntiCloudflareChallengeTask"); var AntiCloudflareChallengeTask = _AntiCloudflareChallengeTask; // src/lib/Requests/Token/AntiCloudflareTurnstileTask.ts var _AntiCloudflareTurnstileTask = class _AntiCloudflareTurnstileTask extends AntiCloudflareTaskBase { /** * Create AntiCloudflareTurnstileTask * @see {@link https://docs.capsolver.com/en/guide/captcha/cloudflare_turnstile/} * @param {Object} params - AntiCloudflareTurnstileTaskParams * @param {string} [params.websiteURL] - The address of the target page. * @param {string=} [params.websiteKey] - Turnstile website key. * @param {object} [params.metadata] - Turnstile extra data {@link https://developers.cloudflare.com/turnstile/get-started/client-side-rendering/} * @param {string} [params.metadata.type] - challenge or turnstile fixed value, default: "turnstile" * @param {string} [params.metadata.cdata] - The value of the data-cdata attribute of the Turnstile element if it exists. * @param {string} [params.proxy] - proxy * @param {string} [params.proxyAddress] - proxyAddress * @param {string} [params.proxyLogin] - proxyLogin * @param {string} [params.proxyPassword] - proxyPassword * @param {string} [params.proxyPort] - proxyPort * @param {string} [params.proxyType] - proxyType */ constructor({ websiteURL, proxy, metadata, websiteKey, proxyAddress, proxyLogin, proxyPassword, proxyPort, proxyType }) { const { action, type = "turnstile", cdata } = metadata || { "type": "turnstile" }; super({ proxy, proxyAddress, proxyLogin, proxyPassword, proxyPort, proxyType, websiteURL }, "AntiCloudflareTask"); /** * @type {boolean} _isAntiCloudflareTask - Only used for correct method overloading intellisense */ __publicField(this, "_isAntiCloudflareTask", true); __publicField(this, "websiteKey"); /** * @type {object} [type.metadata] - Turnstile extra data {@link https://developers.cloudflare.com/turnstile/get-started/client-side-rendering/} * @type {string} [type.metadata.type] - challenge or turnstile fixed value. * @type {string} [type.proxy] - proxy * @type {string} [type.websiteURL] - The URL of the page that returns the captcha info */ __publicField(this, "metadata"); this.websiteKey = websiteKey; this.metadata = { action, cdata, type }; } }; __name(_AntiCloudflareTurnstileTask, "AntiCloudflareTurnstileTask"); var AntiCloudflareTurnstileTask = _AntiCloudflareTurnstileTask; // src/lib/Requests/Token/Base/_AntiTurnstileTaskProxyLessBase.ts var _AntiTurnstileTaskProxyLessBase = class _AntiTurnstileTaskProxyLessBase extends BaseTask { /** * Create AntiTurnstileTaskProxyLess * @see {@link https://docs.capsolver.com/en/guide/captcha/cloudflare_turnstile/} * @param {object} params - AntiTurnstileTaskProxyLessBaseParams * @param {string} [params.websiteURL] - The address of the target page. * @param {string} [params.websiteKey] - Turnstile website key. * @param {Object} [params.metadata] - Turnstile extra data. @see https://developers.cloudflare.com/turnstile/get-started/client-side-rendering/ * @param {string=} [params.metdata.action] - The value of the data-action attribute of the Turnstile element if it exists. * @param {string=} [params.metadata.cdata] - The value of the data-cdata attribute of the Turnstile element if it exists. */ constructor({ websiteURL, websiteKey, metadata }, type) { super({ type }); /** * @type {string} websiteKey - Turnstile website key. */ __publicField(this, "websiteKey"); /** * @type {Object} metadata - Turnstile extra data. @see https://developers.cloudflare.com/turnstile/get-started/client-side-rendering/ * @type {string=?} [metdata.action] - The value of the data-action attribute of the Turnstile element if it exists. * @type {string=?} [metadata.cdata] - The value of the data-cdata attribute of the Turnstile element if it exists. */ __publicField(this, "metadata"); /** * @type {string} websiteURL - The address of the target page. */ __publicField(this, "websiteURL"); this.websiteURL = websiteURL; this.metadata = metadata; this.websiteKey = websiteKey; } }; __name(_AntiTurnstileTaskProxyLessBase, "AntiTurnstileTaskProxyLessBase"); var AntiTurnstileTaskProxyLessBase = _AntiTurnstileTaskProxyLessBase; // src/lib/Requests/Token/AntiTurnstileTaskProxyLess.ts var _AntiTurnstileTaskProxyLess = class _AntiTurnstileTaskProxyLess extends AntiTurnstileTaskProxyLessBase { /** * Create AntiTurnstileTaskProxyLess * @see {@link https://docs.capsolver.com/en/guide/captcha/cloudflare_turnstile/} * @param {object} params - AntiCloudflareTaskParams * @param {string} [params.websiteURL] - The address of the target page. * @param {string} [params.websiteKey] - Turnstile website key. * @param {Object} [params.metadata] - Turnstile extra data. @see https://developers.cloudflare.com/turnstile/get-started/client-side-rendering/ * @param {string=} [params.metdata.action] - The value of the data-action attribute of the Turnstile element if it exists. * @param {string=} [params.metadata.cdata] - The value of the data-cdata attribute of the Turnstile element if it exists. */ constructor({ websiteURL, websiteKey, metadata }) { super({ metadata, websiteKey, websiteURL }, "AntiTurnstileTaskProxyLess"); /** * @type {boolean} _isAntiTurnstileTaskProxyLess - Only used for correct method overloading intellisense */ __publicField(this, "_isAntiTurnstileTaskProxyLess", true); } }; __name(_AntiTurnstileTaskProxyLess, "AntiTurnstileTaskProxyLess"); var AntiTurnstileTaskProxyLess = _AntiTurnstileTaskProxyLess; // src/lib/Requests/Token/Base/_AntiCyberSiAraBase.ts var _AntiCyberSiAraTaskBase = class _AntiCyberSiAraTaskBase extends BaseTask { /** * Create AntiCyberSiAraTaskBase * @see {@link https://docs.capsolver.com/guide/captcha/CyberSiara.html} * @param {Object} params - AntiCyberSiAraTaskBaseParams * @param {string} [params.SlideMasterUrlId] - you can get MasterUrlId param form api/CyberSiara/GetCyberSiara endpoint * @param {string} [params.userAgent] - browser userAgent,you need submit your userAgent * @param {string} [params.websiteURL] - the current website home page url * @param {string} [params.proxy] - proxy * @param {string} [params.proxyAddress] - proxyAddress * @param {string} [params.proxyLogin] - proxyLogin * @param {string} [params.proxyPassword] - proxyPassword * @param {string} [params.proxyPort] - proxyPort * @param {string} [params.proxyType] - proxyType */ constructor({ proxy, SlideMasterUrlId, userAgent, websiteURL, proxyAddress, proxyPort, proxyType, proxyLogin, proxyPassword }, type) { super({ type }); /** * @type {string} SlideMasterUrlId - you can get MasterUrlId param form api/CyberSiara/GetCyberSiara endpoint */ __publicField(this, "SlideMasterUrlId"); /** * @type {string} userAgent - browser userAgent,you need submit your userAgent */ __publicField(this, "userAgent"); /** * @type {string=} proxy - proxy */ __publicField(this, "proxy"); /** * @type {string} websiteURL - the current website home page url */ __publicField(this, "websiteURL"); __publicField(this, "proxyAddress"); __publicField(this, "proxyLogin"); __publicField(this, "proxyPassword"); __publicField(this, "proxyPort"); __publicField(this, "proxyType"); this.SlideMasterUrlId = SlideMasterUrlId; this.userAgent = userAgent; this.websiteURL = websiteURL; this.proxy = proxy; this.proxyAddress = proxyAddress; this.proxyLogin = proxyLogin; this.proxyPort = proxyPort; this.proxyType = proxyType; this.proxyPassword = proxyPassword; } }; __name(_AntiCyberSiAraTaskBase, "AntiCyberSiAraTaskBase"); var AntiCyberSiAraTaskBase = _AntiCyberSiAraTaskBase; // src/lib/Requests/Token/AntiCyberSiAraTask.ts var _AntiCyberSiAraTask = class _AntiCyberSiAraTask extends AntiCyberSiAraTaskBase { /** * Create AntiCyberSiAraT