diff --git a/capsolver/README.md b/capsolver/README.md index 6f65eaa..6bafecb 100644 --- a/capsolver/README.md +++ b/capsolver/README.md @@ -8,40 +8,62 @@ Docs: https://docs.capsolver.com ## Installation Via [npm](https://www.npmjs.com/package/@captcha-libs/capsolver) ```npm i @captcha-libs/capsolver``` +pnpm + ```$ pnpm i @captcha-libs/capsolver``` +yarn + ```$ yarn add @captcha-libs/capsolver``` -Usage +### Usage ```javascript +//import CapSolver client and desired task import { CapSolver, ReCaptchaV3EnterpriseTask } from "@captcha-libs/capsolver"; const capsolverClient = new CapSolver({ clientKey: "", - pollingInterval: 5000, //optional. Delay in milliseconds to fetch task result, default: 5000ms - timeout: 120_000 //optional. Max time in milliseconds to wait for settled task result, default: 120000ms + pollingInterval: 5000, // optional. Delay in milliseconds to fetch task result, default: 5000ms + timeout: 120_000 // optional. Max time in milliseconds to wait for settled task result, default: 120000ms }); + +// Pass captcha params to solve const reCaptchaV3Request = new ReCaptchaV3EnterpriseTask({ - proxy: "http:ip:port:user:pass", - websiteKey: "6Le-wvkSAAAAAPBMRTvw0Q4Muexq9bi0DJwx_mJ-", - websiteURL: "https://www.google.com/recaptcha/api2/demo" -}); + proxy: "http:ip:port:user:pass", + websiteKey: "6Le-wvkSAAAAAPBMRTvw0Q4Muexq9bi0DJwx_mJ-", + websiteURL: "https://www.google.com/recaptcha/api2/demo" +}); +// returns solution or throws an exception const reCaptchaV3Solution = await capsolverClient.solve(reCaptchaV3Request); const { - solution: { expireTime, gRecaptchaResponse, userAgent, taskId } + solution, //returns generic captcha type specific solution + errorId, + errorCode, + errorDescription, + status } = reCaptchaV3Solution; +const { + gRecaptchaResponse, userAgent, expireTime +} = solution; + //if you want to submit feedback const feedback = await capsolverClient.feedbackTask({ - taskId, - invalid: false, //is captcha solved successfully? required. - message: "success", //optional - code: 1, //optional + taskId, + invalid: false, //is captcha solved successfully? required. + message: "success", //optional + code: 1, //optional }); //to get balance const balance = await capsolverClient.getBalance() ``` +### Features +* Supports all captcha types, solutions and methods from CapSolver docs (updated at Feb. 2024) +* TypeScript-first design +* Automatically waits for solution +* Fully tested task payloads + ### Currently supported task payloads What 'custom' does mean? Custom means that the parameters and solutions have been narrowed down from the official documentation from more general cases. However, you can still use classes strictly according to the official documentation. diff --git a/capsolver/package-lock.json b/capsolver/package-lock.json new file mode 100644 index 0000000..877f94e --- /dev/null +++ b/capsolver/package-lock.json @@ -0,0 +1,85 @@ +{ + "name": "@captcha-libs/capsolver", + "version": "1.1.4", + "lockfileVersion": 2, + "requires": true, + "packages": { + "": { + "name": "@captcha-libs/capsolver", + "version": "1.1.4", + "license": "ISC", + "dependencies": { + "@captcha-libs/captcha-client": "latest", + "ofetch": "^1.3.3" + } + }, + "node_modules/@captcha-libs/captcha-client": { + "version": "0.0.5", + "resolved": "https://registry.npmjs.org/@captcha-libs/captcha-client/-/captcha-client-0.0.5.tgz", + "integrity": "sha512-oz0LIWvN0gvrE3RaJfwkwy3Sf+YVpzD8Fd2Xaqnpev+RJ7/rynHa0rupFd2W2PGFoGNR72oZWvb+ESBl6vrA8Q==", + "dependencies": { + "ofetch": "^1.3.3" + } + }, + "node_modules/destr": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/destr/-/destr-2.0.2.tgz", + "integrity": "sha512-65AlobnZMiCET00KaFFjUefxDX0khFA/E4myqZ7a6Sq1yZtR8+FVIvilVX66vF2uobSumxooYZChiRPCKNqhmg==" + }, + "node_modules/node-fetch-native": { + "version": "1.6.1", + "resolved": "https://registry.npmjs.org/node-fetch-native/-/node-fetch-native-1.6.1.tgz", + "integrity": "sha512-bW9T/uJDPAJB2YNYEpWzE54U5O3MQidXsOyTfnbKYtTtFexRvGzb1waphBN4ZwP6EcIvYYEOwW0b72BpAqydTw==" + }, + "node_modules/ofetch": { + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/ofetch/-/ofetch-1.3.3.tgz", + "integrity": "sha512-s1ZCMmQWXy4b5K/TW9i/DtiN8Ku+xCiHcjQ6/J/nDdssirrQNOoB165Zu8EqLMA2lln1JUth9a0aW9Ap2ctrUg==", + "dependencies": { + "destr": "^2.0.1", + "node-fetch-native": "^1.4.0", + "ufo": "^1.3.0" + } + }, + "node_modules/ufo": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/ufo/-/ufo-1.3.2.tgz", + "integrity": "sha512-o+ORpgGwaYQXgqGDwd+hkS4PuZ3QnmqMMxRuajK/a38L6fTpcE5GPIfrf+L/KemFzfUpeUQc1rRS1iDBozvnFA==" + } + }, + "dependencies": { + "@captcha-libs/captcha-client": { + "version": "0.0.5", + "resolved": "https://registry.npmjs.org/@captcha-libs/captcha-client/-/captcha-client-0.0.5.tgz", + "integrity": "sha512-oz0LIWvN0gvrE3RaJfwkwy3Sf+YVpzD8Fd2Xaqnpev+RJ7/rynHa0rupFd2W2PGFoGNR72oZWvb+ESBl6vrA8Q==", + "requires": { + "ofetch": "^1.3.3" + } + }, + "destr": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/destr/-/destr-2.0.2.tgz", + "integrity": "sha512-65AlobnZMiCET00KaFFjUefxDX0khFA/E4myqZ7a6Sq1yZtR8+FVIvilVX66vF2uobSumxooYZChiRPCKNqhmg==" + }, + "node-fetch-native": { + "version": "1.6.1", + "resolved": "https://registry.npmjs.org/node-fetch-native/-/node-fetch-native-1.6.1.tgz", + "integrity": "sha512-bW9T/uJDPAJB2YNYEpWzE54U5O3MQidXsOyTfnbKYtTtFexRvGzb1waphBN4ZwP6EcIvYYEOwW0b72BpAqydTw==" + }, + "ofetch": { + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/ofetch/-/ofetch-1.3.3.tgz", + "integrity": "sha512-s1ZCMmQWXy4b5K/TW9i/DtiN8Ku+xCiHcjQ6/J/nDdssirrQNOoB165Zu8EqLMA2lln1JUth9a0aW9Ap2ctrUg==", + "requires": { + "destr": "^2.0.1", + "node-fetch-native": "^1.4.0", + "ufo": "^1.3.0" + } + }, + "ufo": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/ufo/-/ufo-1.3.2.tgz", + "integrity": "sha512-o+ORpgGwaYQXgqGDwd+hkS4PuZ3QnmqMMxRuajK/a38L6fTpcE5GPIfrf+L/KemFzfUpeUQc1rRS1iDBozvnFA==" + } + } +}