rucaptcha-2captcha
Advanced tools
Comparing version 1.0.2 to 1.0.3
{ | ||
"name": "rucaptcha-2captcha", | ||
"version": "1.0.2", | ||
"description": "Operates with RuCaptcha.com and 2Captcha.com conveniently.", | ||
"version": "1.0.3", | ||
"description": "Operates with RuCaptcha.com and 2Captcha.com services conveniently.", | ||
"main": "ruCaptcha2Captcha.js", | ||
@@ -6,0 +6,0 @@ "scripts": {}, |
135
README.md
@@ -1,12 +0,12 @@ | ||
[![All dependencies](https://img.shields.io/librariesio/release/npm/rucaptcha-2captcha/1.0.2?style=flat-square "All dependencies of rucaptcha-2captcha@1.0.2")](https://libraries.io/npm/rucaptcha-2captcha/1.0.2) | ||
[![Reported vulnerabilities](https://img.shields.io/snyk/vulnerabilities/npm/rucaptcha-2captcha@1.0.2?style=flat-square "Reported vulnerabilities of rucaptcha-2captcha@1.0.2")](https://snyk.io/test/npm/rucaptcha-2captcha/1.0.2) | ||
[![NPM-version](https://img.shields.io/badge/npm-v1.0.2-blue.svg?style=flat-square&&logo=npm "Current NPM-version")](https://www.npmjs.com/package/rucaptcha-2captcha/v/1.0.2) | ||
[![Install size](https://flat.badgen.net/packagephobia/install/rucaptcha-2captcha@1.0.2?label=size 'Install size of rucaptcha-2captcha@1.0.2')](https://packagephobia.now.sh/result?p=rucaptcha-2captcha@1.0.2) | ||
[![All dependencies](https://img.shields.io/librariesio/release/npm/rucaptcha-2captcha/1.0.3?style=flat-square "All dependencies of rucaptcha-2captcha@1.0.3")](https://libraries.io/npm/rucaptcha-2captcha/1.0.3) | ||
[![Reported vulnerabilities](https://img.shields.io/snyk/vulnerabilities/npm/rucaptcha-2captcha@1.0.3?style=flat-square "Reported vulnerabilities of rucaptcha-2captcha@1.0.3")](https://snyk.io/test/npm/rucaptcha-2captcha/1.0.3) | ||
[![NPM-version](https://img.shields.io/badge/npm-v1.0.3-blue.svg?style=flat-square&&logo=npm "Current NPM-version")](https://www.npmjs.com/package/rucaptcha-2captcha/v/1.0.3) | ||
[![Install size](https://flat.badgen.net/packagephobia/install/rucaptcha-2captcha@1.0.3?label=size 'Install size of rucaptcha-2captcha@1.0.3')](https://packagephobia.now.sh/result?p=rucaptcha-2captcha@1.0.3) | ||
[![Total downloads](https://img.shields.io/npm/dt/rucaptcha-2captcha?style=flat-square "Total downloads for all the time")](https://npm-stat.com/charts.html?package=rucaptcha-2captcha) | ||
# rucaptcha-2captcha@1.0.2 | ||
# rucaptcha-2captcha@1.0.3 | ||
Helps you to operate with [RuCaptcha](https://rucaptcha.com) or [2Captcha](https://2captcha.com) conveniently. | ||
Helps you to operate with [RuCaptcha] or [2Captcha] services conveniently. | ||
Full documentation you can find on [https://rucaptcha.com/api-rucaptcha](https://rucaptcha.com/api-rucaptcha) and [https://2captcha.com/2captcha-api](https://2captcha.com/2captcha-api) respectively. | ||
Full documentation you can find on official sites: [RuCaptcha][RuCaptchaAPI], [2Captcha][2CaptchaAPI]. | ||
@@ -16,3 +16,3 @@ ## Installation | ||
``` bash | ||
$ npm i rucaptcha-2captcha@1.0.2 | ||
$ npm i rucaptcha-2captcha@1.0.3 | ||
``` | ||
@@ -22,2 +22,12 @@ | ||
### Initialization | ||
#### Synopsis | ||
new RuCaptcha2Captcha(apiKey[, type]) → captchaSolver object | ||
| Parameter | Type | Required | Description | ||
|-----------|--------|----------|- | ||
| apiKey | string | true | Your account API key from settings ([RuCaptcha][RuCaptchaSettings] \| [2Captcha][2CaptchaSettings]) | ||
| type | string | false | Case insensitive **'2captcha'** for [2Captcha]. Any other for [RuCaptcha]. | ||
#### Example | ||
```js | ||
@@ -27,2 +37,3 @@ const RuCaptcha2Captcha = require('rucaptcha-2captcha'); | ||
const captchaSolver = new RuCaptcha2Captcha(<YOUR_API_KEY>); | ||
// or for operating with 2Captcha.com | ||
@@ -32,8 +43,15 @@ const captchaSolver = new RuCaptcha2Captcha(<YOUR_API_KEY>, '2captcha'); | ||
``` | ||
**<YOUR_API_KEY>** you can find in your account settings ([RuCaptcha](https://rucaptcha.com/setting) | [2Captcha](https://2captcha.com/setting)) | ||
### captchaSolver.send method | ||
#### Synopsis | ||
Use this method to send captcha for solve. Returns `Promise<capthca_id>`.\ | ||
For example: | ||
captchaSolver.send(params) → `Promise<captcha_id>` | ||
| Parameter | Type | Required | Description | ||
|-----------|--------|----------|- | ||
| params | object | true | Object with params from documentation ([RuCaptcha][RuCaptchaParams] \| [2Captcha][2CaptchaParams]) except `key`, `json` and `soft_id` | ||
Use this method to send captcha for solve. | ||
#### Example | ||
```js | ||
@@ -43,2 +61,4 @@ const id = await captchaSolver.send({ | ||
body: <base64_image_body>, | ||
// any other parameter from API | ||
// except: key, json and soft_id | ||
}); | ||
@@ -49,6 +69,15 @@ | ||
### captchaSolver.sendFile method | ||
### captchaSolver.sendFile custom method over captchaSolver.send | ||
#### Synopsis | ||
Use this method to send captcha as image from your local file system. Returns `Promise<capthca_id>`.\ | ||
For example: | ||
captchaSolver.sendFile(filePath[, params]) → `Promise<captcha_id>` | ||
| Parameter | Type | Required | Description | ||
|-----------|--------|----------|- | ||
| filePath | string | true | Path to captcha image on your file system | ||
| params | object | false | Object with params from documentation ([RuCaptcha][RuCaptchaParams] \| [2Captcha][2CaptchaParams]) except `method`, `file`, `body`, `key`, `json` and `soft_id` | ||
Use this method to send captcha as image from your local file system. | ||
#### Example | ||
```js | ||
@@ -60,2 +89,4 @@ const id = await captchaSolver.sendFile('./captcha.jpg', { | ||
numeric: 4, | ||
// any other parameter from API | ||
// except: method, file, body, key, json and soft_id | ||
}); | ||
@@ -67,24 +98,47 @@ | ||
### captchaSolver.get method | ||
#### Synopsis | ||
Method for getting captcha solutions. Returns `Promise<captcha_token>` or `Promise<Array<captcha_token>>` which resolves as soon as captcha(s) will be solved on service. | ||
captchaSolver.get(id | ids | strIds) → `Promise<captcha_token>` | `Promise<Array<captcha_token>>` | ||
| Parameter | Type | Required | Description | ||
|-----------|-----------|------------|- | ||
| id | string | one of all | Captcha id, sent for solution | ||
| ids | Array<id> | one of all | Array of captcha ids | ||
| strIds | string | one of all | String of comma separated captcha ids | ||
Method for getting captcha solutions. Returns promise which resolves as soon as captcha (all captchas) will be solved on service. | ||
#### Example | ||
```js | ||
const token = await catpchaSolver.get(id); | ||
const token = await captchaSolver.get(id); | ||
// token: 'ABCD' | ||
// or | ||
const tokens = await catpchaSolver.get([id1, id2, ...]); | ||
const tokens = await captchaSolver.get([id1, id2, ...]); | ||
// tokens: ['ABCD', 'abcd', ...] | ||
// or | ||
const tokens = await catpchaSolver.get('<id1>,<id2>,...'); | ||
const tokens = await captchaSolver.get('<id1>,<id2>,...'); | ||
// tokens: ['ABCD', 'abcd', ...] | ||
``` | ||
### captchaSolver.reportGood and captchaSolver.reportBad methods | ||
### Solution reporting methods | ||
#### Synopsis | ||
Use these methods for reporting captcha results. It's not necessary but better to send reports cause of refund of bad solutions and increasing solving accuracy by reporting good solutions. | ||
captchaSolver.reportGood(id) →`Promise<Object>`\ | ||
captchaSolver.reportBad(id) →`Promise<Object>` | ||
| Parameter | Type | Required | Description | ||
|-----------|--------|----------|- | ||
| id | string | true | Captcha id, sent for solution | ||
Use these methods for reporting captcha results.\ | ||
**Attention!** It's not necessary but better to send reports cause of refund of bad solutions and increasing solving accuracy by reporting good solutions.\ | ||
Returns some info that was sent from server. | ||
#### Example | ||
```js | ||
const result = await catpchaSolver.reportGood(id); | ||
const result = await captchaSolver.reportGood(id); | ||
// or | ||
const result = await catpchaSolver.reportBad(id); | ||
const result = await captchaSolver.reportBad(id); | ||
// result: { status: 1, request: 'OK_REPORT_RECORDED' } | ||
@@ -94,6 +148,15 @@ ``` | ||
### captchaSolver.get2 method | ||
#### Synopsis | ||
Use captchaSolver.get2 method for getting captcha answer with its cost price. Returns `Promise<Object>`. | ||
captchaSolver.get2(id) → `Promise<Object>` | ||
| Parameter | Type | Required | Description | ||
|-----------|--------|----------|- | ||
| id | string | true | Captcha id, sent for solution | ||
Use captchaSolver.get2 method for getting captcha answer with its cost price. | ||
#### Example | ||
```js | ||
const info = await catpchaSolver.get2(id); | ||
const info = await captchaSolver.get2(id); | ||
// info: { request: '6p6pck', price: '0.034' } | ||
@@ -103,16 +166,19 @@ ``` | ||
### captchaSolver.getBalance method | ||
#### Synopsis | ||
Use for getting your account balance. | ||
captchaSolver.captchaSolver.getBalance() → `Promise<number>` | ||
Use for getting your account balance.\ | ||
Note: don't use it too often because it decreases your API query limit. | ||
#### Example | ||
```js | ||
const balance = await catpchaSolver.getBalance(); | ||
const balance = await captchaSolver.getBalance(); | ||
// balance: 50.034 | ||
``` | ||
Note: don't use it too often because it decreases your query limit to **RuCaptcha** (**2Captcha**) server. | ||
--- | ||
Note that **json**, **key** and **soft_id** are not writable parameters of any method. | ||
More info you can find in documentation ([RuCaptcha][RuCaptchaAPI] | [2Captcha][2CaptchaAPI]). | ||
More info you can find in documentation ([RuCaptcha](https://rucaptcha.com/api-rucaptcha) | [2Captcha](https://2captcha.com/2captcha-api)). | ||
## Testing | ||
@@ -124,1 +190,10 @@ No testing functionality provided. | ||
Your improve suggestions and bug reports are welcome any time. | ||
[RuCaptcha]: https://rucaptcha.com | ||
[2Captcha]: https://2captcha.com | ||
[RuCaptchaAPI]: https://rucaptcha.com/api-rucaptcha | ||
[2CaptchaAPI]: https://2captcha.com/2captcha-api | ||
[RuCaptchaSettings]: https://rucaptcha.com/setting | ||
[2CaptchaSettings]: https://2captcha.com/setting | ||
[RuCaptchaParams]: https://rucaptcha.com/api-rucaptcha#normal_post | ||
[2CaptchaParams]: https://2captcha.com/2captcha-api#normal_post |
@@ -9,3 +9,3 @@ 'use strict'; | ||
function throwErrorOfBadStatus(status, data) { | ||
if(!status) { | ||
if(!status && data.request !== 'CAPCHA_NOT_READY') { | ||
const e = new Error(data.error_text); | ||
@@ -17,3 +17,7 @@ e.name = data.request; | ||
module.exports = function(key, twoCaptcha = '') { | ||
function RuCaptcha2Captcha(key, twoCaptcha = '') { | ||
if(!new.target) { | ||
return new RuCaptcha2Captcha(key, twoCaptcha); | ||
} | ||
const ruOr2 = String(twoCaptcha).toLowerCase().trim() === '2captcha' ? 2 : 'ru'; | ||
@@ -25,5 +29,5 @@ const sendUrl = `https://${ruOr2}captcha.com/in.php`; | ||
this.send = async (p = {}) => { | ||
this.send = async parameters => { | ||
const params = { | ||
...p, | ||
...parameters, | ||
key, | ||
@@ -39,3 +43,3 @@ json: 1, | ||
const method = (params.method || '').toLowerCase(); | ||
const timeToWaitInSeconds = ['post', 'base64'].includes(method) && params.recaptcha == null && params.coordinatescaptcha == null | ||
const timeToWaitInSeconds = ['post', 'base64', ''].includes(method) && params.recaptcha == null && params.coordinatescaptcha == null | ||
? 5 | ||
@@ -48,4 +52,4 @@ : 20; | ||
this.sendFile = (file, params = {}) => { | ||
const body = fs.readFileSync(file).toString('base64'); | ||
this.sendFile = (filePath, { file, ...params } = {}) => { | ||
const body = fs.readFileSync(filePath).toString('base64'); | ||
@@ -139,3 +143,2 @@ return this.send({ | ||
} | ||
}; | ||
@@ -158,1 +161,3 @@ }; | ||
}; | ||
module.exports = RuCaptcha2Captcha; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
10979
127
189