-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13 from blackravenx/Capsolver
Capsolver
- Loading branch information
Showing
11 changed files
with
191 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,28 @@ | ||
{ | ||
"name": "@captcha-libs/capsolver", | ||
"version": "1.1.5", | ||
"version": "1.1.7", | ||
"keywords": [ | ||
"CapSolver", | ||
"Captcha recognition", | ||
"Captcha solving", | ||
"ReCaptcha captcha", | ||
"DataDome captcha", | ||
"HCaptcha captcha", | ||
"GeeTest captcha", | ||
"MtCaptcha", | ||
"AWS WAF captcha", | ||
"Cloudflare captcha" | ||
"CapSolver", | ||
"Captcha recognition", | ||
"Captcha solving", | ||
"ReCaptcha captcha", | ||
"DataDome captcha", | ||
"HCaptcha captcha", | ||
"GeeTest captcha", | ||
"MtCaptcha", | ||
"AWS WAF captcha", | ||
"Cloudflare captcha" | ||
], | ||
"license": "ISC", | ||
"author": "Max Shy", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/blackravenx/captcha-libs.git", | ||
"directory": "capsolver" | ||
"type": "git", | ||
"url": "https://github.com/blackravenx/captcha-libs.git", | ||
"directory": "capsolver" | ||
}, | ||
"dependencies": { | ||
"@captcha-libs/captcha-client": "latest", | ||
"ofetch": "^1.3.3" | ||
"@captcha-libs/captcha-client": "latest", | ||
"ofetch": "^1.3.3" | ||
}, | ||
"description": "CapSolver NodeJS client, captcha recognition service" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
import type { _IsTaskType } from "../_BaseTaskRequest"; | ||
import { BaseTask } from "../_BaseTaskRequest"; | ||
|
||
const _VisionEngineModules = [ | ||
"slider_1", | ||
"rotate_1", | ||
"space_detection" | ||
] as const; | ||
|
||
type VisionEngineModules = typeof _VisionEngineModules[number]; | ||
|
||
interface VisionEngineParams { | ||
image: string; | ||
imageBackground: string; | ||
module: VisionEngineModules; | ||
question?: string; | ||
websiteURL?: string; | ||
} | ||
|
||
/** | ||
* @classdesc OCR VisionEngine | ||
* @class | ||
* @extends {BaseTask} | ||
* {@link https://docs.capsolver.com/guide/recognition/VisionEngine.html} | ||
*/ | ||
export class VisionEngine extends BaseTask implements VisionEngineParams, _IsTaskType { | ||
|
||
/** | ||
* @type {boolean} _isVisionEngine - Only used for correct method overloading intellisense | ||
*/ | ||
readonly _isVisionEngine: _IsTaskType["_isVisionEngine"] = true; | ||
|
||
/** | ||
* Create VisionEngine | ||
* {@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 | ||
}: VisionEngineParams) { | ||
super({ type: "VisionEngine" }); | ||
this.image = image; | ||
this.imageBackground = imageBackground; | ||
this.question = question; | ||
this.module = module; | ||
this.websiteURL = websiteURL; | ||
} | ||
|
||
/** | ||
* @type {string} image - base64 encoded content of the image (no newlines, no data:image/***;charset=utf-8;base64,) | ||
*/ | ||
image: string; | ||
|
||
/** | ||
* @type {string} image - base64 encoded content of the image (no newlines, no data:image/***;charset=utf-8;base64,) | ||
*/ | ||
imageBackground: string; | ||
|
||
/** | ||
* @type {VisionEngineModules=} module - Specifies the module | ||
* {@see https://docs.capsolver.com/guide/recognition/VisionEngine.html} | ||
*/ | ||
module: VisionEngineModules; | ||
|
||
/** | ||
* @param {string} question - required for "space_detection" module | ||
*/ | ||
question?: string; | ||
|
||
/** | ||
* @type {string} websiteURL - Page source url to improve accuracy | ||
*/ | ||
websiteURL?: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,15 @@ | ||
import type { AwsWafClassification } from "./AwsWafClassification"; | ||
import type { FunCaptchaClassification } from "./FunCaptchaClassification"; | ||
import type { HCaptchaClassification } from "./HCaptchaClassification"; | ||
import type { ImageToTextTask } from "./ImageToTextTask"; | ||
import type { ReCaptchaV2Classification } from "./ReCaptchaV2Classification"; | ||
import { AwsWafClassification } from "./AwsWafClassification"; | ||
import { FunCaptchaClassification } from "./FunCaptchaClassification"; | ||
import { HCaptchaClassification } from "./HCaptchaClassification"; | ||
import { ImageToTextTask } from "./ImageToTextTask"; | ||
import { ReCaptchaV2Classification } from "./ReCaptchaV2Classification"; | ||
import { VisionEngine } from "./VisionEngine"; | ||
|
||
export { | ||
AwsWafClassification, | ||
FunCaptchaClassification, | ||
HCaptchaClassification, | ||
ImageToTextTask, | ||
ReCaptchaV2Classification | ||
ReCaptchaV2Classification, | ||
VisionEngine | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
capsolver/src/lib/Solution/Classification/VisionEngineSolution.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
|
||
interface VisionEngineAngleSolution { | ||
angle: number; | ||
} | ||
|
||
interface VisionEngineDistanceSolution { | ||
distance: number; | ||
} | ||
|
||
interface VisionEngineSpaceDetectionSolution { | ||
box: number[]; | ||
} | ||
|
||
/** | ||
* {@link https://docs.capsolver.com/guide/recognition/VisionEngine.html#example-response} | ||
*/ | ||
export type VisionEngineSolution = VisionEngineAngleSolution & VisionEngineDistanceSolution & VisionEngineSpaceDetectionSolution; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,15 @@ | ||
import type { AwsWafClassificationSolution } from "./AwsWafClassificationSolution"; | ||
import type { FunCaptchaClassificationSolution } from "./FunCaptchaClassificationSolution"; | ||
import type { HCaptchaClassificationSolution } from "./HCaptchaClassificationSolution"; | ||
import type { ImageToTextSolution } from "./ImageToTextSolution"; | ||
import type { ReCaptchaV2ClassificationSolution } from "./ReCaptchaV2ClassificationSolution"; | ||
import { VisionEngineSolution } from "./VisionEngineSolution"; | ||
import { AwsWafClassificationSolution } from "./AwsWafClassificationSolution"; | ||
import { FunCaptchaClassificationSolution } from "./FunCaptchaClassificationSolution"; | ||
import { HCaptchaClassificationSolution } from "./HCaptchaClassificationSolution"; | ||
import { ImageToTextSolution } from "./ImageToTextSolution"; | ||
import { ReCaptchaV2ClassificationSolution } from "./ReCaptchaV2ClassificationSolution"; | ||
|
||
export { | ||
AwsWafClassificationSolution, | ||
FunCaptchaClassificationSolution, | ||
HCaptchaClassificationSolution, | ||
ImageToTextSolution, | ||
ReCaptchaV2ClassificationSolution | ||
ReCaptchaV2ClassificationSolution, | ||
VisionEngineSolution | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
capsolver/src/tests/Requests/Classification/VisionEngine.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { VisionEngine } from "../../../lib/Requests/Classification/VisionEngine"; | ||
|
||
describe("VisionEngine Test", () => { | ||
it("To be equal to object", () => { | ||
const task = new VisionEngine({ | ||
image: "image-base64", | ||
imageBackground: "imageBackground-base64", | ||
module: "rotate_1", | ||
question: "question", | ||
websiteURL: "https://some-url.com" | ||
}); | ||
|
||
expect(task).toEqual({ | ||
_endpoint: "createTask", | ||
_isVisionEngine: true, | ||
image: "image-base64", | ||
imageBackground: "imageBackground-base64", | ||
module: "rotate_1", | ||
question: "question", | ||
type: "VisionEngine", | ||
websiteURL: "https://some-url.com" | ||
}); | ||
}); | ||
it("To be equal to object without optional params", () => { | ||
const task = new VisionEngine({ | ||
image: "image-base64", | ||
imageBackground: "imageBackground-base64", | ||
module: "rotate_1" | ||
}); | ||
|
||
expect(task).toEqual({ | ||
_endpoint: "createTask", | ||
_isVisionEngine: true, | ||
image: "image-base64", | ||
imageBackground: "imageBackground-base64", | ||
module: "rotate_1", | ||
question: undefined, | ||
type: "VisionEngine", | ||
websiteURL: undefined | ||
}); | ||
}); | ||
}); |