Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update package #10

Merged
merged 1 commit into from
Feb 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ module.exports = {
"tailwindcss/classnames-order": "off",

"template-curly-spacing": "error",
"@typescript-eslint/consistent-type-imports": "off",
"@typescript-eslint/consistent-type-imports": "error",
"unused-imports/no-unused-imports": [
"warn", {
args: "after-used",
Expand Down
26 changes: 23 additions & 3 deletions capsolver/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ yarn
### Usage
```javascript
//import CapSolver client and desired task
import { CapSolver, ReCaptchaV3EnterpriseTask } from "@captcha-libs/capsolver";
import { CapSolver, ReCaptchaV3EnterpriseTaskProxyLess } from "@captcha-libs/capsolver";

const capsolverClient = new CapSolver({
clientKey: "<YOUR_CLIENT_KEY>",
Expand All @@ -25,8 +25,7 @@ const capsolverClient = new CapSolver({
});

// Pass captcha params to solve
const reCaptchaV3Request = new ReCaptchaV3EnterpriseTask({
proxy: "http:ip:port:user:pass",
const reCaptchaV3Request = new ReCaptchaV3EnterpriseTaskProxyLess({
websiteKey: "6Le-wvkSAAAAAPBMRTvw0Q4Muexq9bi0DJwx_mJ-",
websiteURL: "https://www.google.com/recaptcha/api2/demo"
});
Expand Down Expand Up @@ -57,7 +56,28 @@ const feedback = await capsolverClient.feedbackTask({
//to get balance
const balance = await capsolverClient.getBalance()
```
### [Usage with proxies](https://docs.capsolver.com/guide/api-how-to-use-proxy.html)
```javascript
const reCaptchaV3Request = new ReCaptchaV3EnterpriseTask({
websiteKey: "6Le-wvkSAAAAAPBMRTvw0Q4Muexq9bi0DJwx_mJ-",
websiteURL: "https://www.google.com/recaptcha/api2/demo",

//------> You can send the proxy information with one of these proxy format, please read carefully

//pass proxy connection string
proxy: "socks5:192.191.100.10:4780:user:pwd",
//or
proxy: "198.199.100.10:4780:user:pwd",

//or use object format
proxyAddress: "198.199.100.10",
proxyType: "https", // socks5 | http | https
proxyLogin: "user",
proxyPassword: "pass",
proxyPort: 3949,
});

```
### Features
* Supports all captcha types, solutions and methods from CapSolver docs (updated at Feb. 2024)
* TypeScript-first design
Expand Down
18 changes: 1 addition & 17 deletions capsolver/index.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,6 @@
import { ReCaptchaV2TaskProxyLess } from "./src/lib/Requests";
import { CapSolver } from "./src/lib/capsolver";

export * from "./src/lib/Requests/Classification";
export * from "./src/lib/Requests/Token";

export { CapSolver };

(async() => {

const capsolver = new CapSolver({ clientKey: "CAP-207EF70B18643D1AE925CE66BB19294A" });

const req = new ReCaptchaV2TaskProxyLess({
isInvisible: true,
websiteKey: "6Le-wvkSAAAAAPBMRTvw0Q4Muexq9bi0DJwx_mJ-",
websiteURL: "https://www.google.com/recaptcha/api2/demo"
});

const solution = await capsolver.solve(req);

console.log({ solution });
})();
export { CapSolver };
4 changes: 2 additions & 2 deletions capsolver/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion capsolver/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@captcha-libs/capsolver",
"version": "1.1.4",
"version": "1.1.5",
"keywords": [
"CapSolver",
"Captcha recognition",
Expand Down
3 changes: 2 additions & 1 deletion capsolver/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"targets": {
"lint": {
"executor": "@nx/eslint:lint",
"outputs": ["{options.outputFile}"]
"outputs": ["{options.outputFile}"],
"options": {"fix": true}
},
"test": {
"executor": "@nx/jest:jest",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import {
BaseTask, type BaseParams, _IsTaskType
} from "../_BaseTaskRequest";
import type { _IsTaskType } from "../_BaseTaskRequest";
import { BaseTask } from "../_BaseTaskRequest";

type AwsWafClassificationParams = Omit<BaseParams, "_endpoint" | "type"> & {
interface AwsWafClassificationParams {
images: Array<string>;
question: string;
websiteKey?: string;
websiteURL?: string;
};
}

/**
* @classdesc AWS WAF Images Recognize
Expand All @@ -16,7 +15,11 @@ type AwsWafClassificationParams = Omit<BaseParams, "_endpoint" | "type"> & {
* {@link https://docs.capsolver.com/guide/recognition/AwsWafClassification.html}
*/
export class AwsWafClassification extends BaseTask implements AwsWafClassificationParams, _IsTaskType {
readonly _isAwsWafClassification = true;

/**
* @type {boolean} _isAwsWafClassification - Only used for correct method overloading intellisense
*/
readonly _isAwsWafClassification: _IsTaskType["_isAwsWafClassification"] = true;

/**
* Create AwsWafClassification
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import {
BaseTask, type BaseParams, _IsTaskType
} from "../_BaseTaskRequest";
import type { _IsTaskType } from "../_BaseTaskRequest";
import { BaseTask } from "../_BaseTaskRequest";

type FunCaptchaClassificationParams = Omit<BaseParams, "_endpoint" | "type"> & {
interface FunCaptchaClassificationParams {
images: string;
module?: string;
question: string;
websiteKey?: string;
websiteURL?: string;
};
}

/**
* @classdesc FunCaptcha Images Recognize
Expand All @@ -17,7 +16,11 @@ type FunCaptchaClassificationParams = Omit<BaseParams, "_endpoint" | "type"> & {
* {@link https://docs.capsolver.com/guide/recognition/FunCaptchaClassification.html}
*/
export class FunCaptchaClassification extends BaseTask implements FunCaptchaClassificationParams, _IsTaskType {
readonly _isFunCaptchaClassification = true;

/**
* @type {boolean} _isFunCaptchaClassification - Only used for correct method overloading intellisense
*/
readonly _isFunCaptchaClassification: _IsTaskType["_isFunCaptchaClassification"] = true;

/**
* Create FunCaptchaClassification
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import {
BaseTask, type BaseParams, _IsTaskType
} from "../_BaseTaskRequest";
import type { _IsTaskType } from "../_BaseTaskRequest";
import { BaseTask } from "../_BaseTaskRequest";

type HCaptchaClassificationParams = Omit<BaseParams, "_endpoint" | "type"> & {
interface HCaptchaClassificationParams {
queries: Array<string>;
question: string;
websiteKey?: string;
websiteURL?: string;
};
}

/**
* @classdesc HCaptcha Images Recognize
Expand All @@ -16,7 +15,11 @@ type HCaptchaClassificationParams = Omit<BaseParams, "_endpoint" | "type"> & {
* {@link https://docs.capsolver.com/guide/recognition/HCaptchaClassification.html}
*/
export class HCaptchaClassification extends BaseTask implements HCaptchaClassificationParams, _IsTaskType {
readonly _isHCaptchaClassification = true;

/**
* @type {boolean} _isHCaptchaClassification - Only used for correct method overloading intellisense
*/
readonly _isHCaptchaClassification: _IsTaskType["_isHCaptchaClassification"] = true;

/**
* Create HCaptchaClassification
Expand Down
21 changes: 10 additions & 11 deletions capsolver/src/lib/Requests/Classification/ImageToTextTask.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import {
BaseTask, type BaseParams, _IsTaskType
} from "../_BaseTaskRequest";
import type { _IsTaskType } from "../_BaseTaskRequest";
import { BaseTask } from "../_BaseTaskRequest";

const _ImageToTextModules = [
"amazon",
Expand All @@ -20,15 +19,15 @@ const _ImageToTextModules = [
"webde-register"
] as const;

type ImageToTextModules =typeof _ImageToTextModules[number];
type ImageToTextModules = typeof _ImageToTextModules[number];

type ImageToTextParams = Omit<BaseParams, "_endpoint" | "type"> & {
interface ImageToTextParams {
body: string;
isCaseSensitive?: boolean;
module?: ImageToTextModules;
score?: number;
websiteURL?: string;
};
}

/**
* @classdesc OCR ImageToText
Expand All @@ -39,9 +38,9 @@ type ImageToTextParams = Omit<BaseParams, "_endpoint" | "type"> & {
export class ImageToTextTask extends BaseTask implements ImageToTextParams, _IsTaskType {

/**
* @type {boolean} _isImageToTextTask - Only used for correct method overloading intellisense
*/
readonly _isImageToTextTask = true;
* @type {boolean} _isImageToTextTask - Only used for correct method overloading intellisense
*/
readonly _isImageToTextTask: _IsTaskType["_isImageToTextTask"] = true;

/**
* Create ImageToTextTask
Expand All @@ -54,13 +53,13 @@ export class ImageToTextTask extends BaseTask implements ImageToTextParams, _IsT
* @param {string} [params.websiteURL] - Page source url to improve accuracy
*/
constructor({
body, isCaseSensitive, module, score, websiteURL
body, isCaseSensitive, module: _module, score, websiteURL
}: ImageToTextParams) {
super({ type: "ImageToTextTask" });
this.body = body;
this.case = isCaseSensitive;
this.score = score;
this.module = module;
this.module = _module;
this.websiteURL = websiteURL;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import {
BaseTask, type BaseParams, _IsTaskType
} from "../_BaseTaskRequest";
import type { _IsTaskType } from "../_BaseTaskRequest";
import { BaseTask } from "../_BaseTaskRequest";

type ReCaptchaClassificationParams = Omit<BaseParams, "_endpoint" | "type"> & {
interface ReCaptchaClassificationParams {
image: string;
question: string;
websiteKey?: string;
websiteURL?: string;
};
}

/**
* @classdesc ReCaptcha Images Recognize
Expand All @@ -16,7 +15,11 @@ type ReCaptchaClassificationParams = Omit<BaseParams, "_endpoint" | "type"> & {
* {@link https://docs.capsolver.com/guide/recognition/ReCaptchaClassification.html}
*/
export class ReCaptchaV2Classification extends BaseTask implements ReCaptchaClassificationParams, _IsTaskType {
readonly _isReCaptchaV2Classification = true;

/**
* @type {boolean} _isReCaptchaV2Classification - Only used for correct method overloading intellisense
*/
readonly _isReCaptchaV2Classification: _IsTaskType["_isReCaptchaV2Classification"] = true;

/**
* Create ReCaptchaV2Classification
Expand Down
15 changes: 7 additions & 8 deletions capsolver/src/lib/Requests/Token/AntiAkamaiBMPTask.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import {
BaseTask, _IsTaskType
} from "../_BaseTaskRequest";
import type { _IsTaskType } from "../_BaseTaskRequest";
import { BaseTask } from "../_BaseTaskRequest";

export type AntiAkamaiBMPTaskParams = {
export interface AntiAkamaiBMPTaskParams {
count?: number;
country?: string;
deviceId?: string;
Expand All @@ -11,7 +10,7 @@ export type AntiAkamaiBMPTaskParams = {
packageName?: string;
pow?: string;
version?: string;
};
}

/**
* @classdesc Class for AntiAkamaiBMPTask. This task type uses a separate endpoint for fetching /akamaibmp/invoke
Expand All @@ -22,9 +21,9 @@ export type AntiAkamaiBMPTaskParams = {
export class AntiAkamaiBMPTask extends BaseTask implements AntiAkamaiBMPTaskParams, _IsTaskType {

/**
* @type {boolean} _isAntiAkamaiBMPTask - Only used for correct method overloading intellisense
*/
readonly _isAntiAkamaiBMPTask = true;
* @type {boolean} _isAntiAkamaiBMPTask - Only used for correct method overloading intellisense
*/
readonly _isAntiAkamaiBMPTask: _IsTaskType["_isAntiAkamaiBMPTask"] = true;

/**
* Create AntiAkamaiBMPTaskBase
Expand Down
13 changes: 6 additions & 7 deletions capsolver/src/lib/Requests/Token/AntiAkamaiPowTask.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import {
BaseTask, _IsTaskType
} from "../_BaseTaskRequest";
import { AntiAkamaiBMPTaskParams } from "./AntiAkamaiBMPTask";
import type { _IsTaskType } from "../_BaseTaskRequest";
import { BaseTask } from "../_BaseTaskRequest";
import type { AntiAkamaiBMPTaskParams } from "./AntiAkamaiBMPTask";

type AntiAkamaiPowTaskParams = Required<Pick<AntiAkamaiBMPTaskParams, "deviceId" | "pow">>;

Expand All @@ -14,9 +13,9 @@ type AntiAkamaiPowTaskParams = Required<Pick<AntiAkamaiBMPTaskParams, "deviceId"
export class AntiAkamaiPowTask extends BaseTask implements AntiAkamaiPowTaskParams, _IsTaskType {

/**
* @type {boolean} _isAntiAkamaiBMPTask - Only used for correct method overloading intellisense
*/
readonly _isAntiAkamaiBMPTask = true;
* @type {boolean} _isAntiAkamaiBMPTask - Only used for correct method overloading intellisense
*/
readonly _isAntiAkamaiBMPTask: _IsTaskType["_isAntiAkamaiBMPTask"] = true;

/**
* Create AntiAkamaiPowTask
Expand Down
13 changes: 6 additions & 7 deletions capsolver/src/lib/Requests/Token/AntiAkamaiSensorTask.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import {
BaseTask, _IsTaskType
} from "../_BaseTaskRequest";
import { AntiAkamaiBMPTaskParams } from "./AntiAkamaiBMPTask";
import type { _IsTaskType } from "../_BaseTaskRequest";
import { BaseTask } from "../_BaseTaskRequest";
import type { AntiAkamaiBMPTaskParams } from "./AntiAkamaiBMPTask";

type AntiAkamaiSensorTaskParams = Omit<AntiAkamaiBMPTaskParams, "pow"> & Required<Pick<AntiAkamaiBMPTaskParams, "packageName" | "version">>;

Expand All @@ -14,9 +13,9 @@ type AntiAkamaiSensorTaskParams = Omit<AntiAkamaiBMPTaskParams, "pow"> & Require
export class AntiAkamaiSensorTask extends BaseTask implements AntiAkamaiSensorTaskParams, _IsTaskType {

/**
* @type {boolean} _isAntiAkamaiBMPTask - Only used for correct method overloading intellisense
*/
readonly _isAntiAkamaiBMPTask = true;
* @type {boolean} _isAntiAkamaiBMPTask - Only used for correct method overloading intellisense
*/
readonly _isAntiAkamaiBMPTask: _IsTaskType["_isAntiAkamaiBMPTask"] = true;

/**
* Create AntiAkamaiSensorTask
Expand Down
Loading
Loading