-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9bdf4ee
commit 6236065
Showing
2 changed files
with
86 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,11 @@ | ||
export { CapmonsterError } from "./capmonster_error" | ||
export { RecaptchaV2Task } from "./tasks/recaptcha_v2" | ||
export { RecaptchaV3Task } from "./tasks/recaptcha_v3" | ||
export { HCaptchaTask } from "./tasks/hcaptcha" | ||
export { ComplexImageTask } from "./tasks/complex_image" | ||
export { FuncaptchaTask } from "./tasks/fun_captcha" | ||
export { TurnstileTask } from "./tasks/turnstile" | ||
export { ImageToTextTask } from "./tasks/image_to_text" | ||
export { GeeTestTask } from "./tasks/geetest" | ||
export { HCaptchaTask } from "./tasks/hcaptcha" | ||
export { ImageToTextTask } from "./tasks/image_to_text" | ||
export { RecaptchaV2Task } from "./tasks/recaptcha_v2" | ||
export { RecaptchaV2EnterpriseTask } from "./tasks/recaptcha_v2_enterprise" | ||
export { ComplexImageTask } from "./tasks/complex_image" | ||
export { RecaptchaV3Task } from "./tasks/recaptcha_v3" | ||
export { TenDITask } from "./tasks/tendi" | ||
export { TurnstileTask } from "./tasks/turnstile" |
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 { ITask, ITaskSolution, UAProxy } from "../capmonster" | ||
|
||
export class TenDITask extends UAProxy { | ||
/** | ||
* Initialize a new TenDITask for handling the captchas | ||
* @param clientKey Unique key of your account | ||
*/ | ||
constructor(clientKey: string) { | ||
super(clientKey) | ||
} | ||
|
||
/** | ||
* Creates only the task configuration for reuseable tasks. | ||
* @param task {@link ITenDITaskRequest} | ||
* @returns Only the task you created {@link ITenDITaskRequest} | ||
*/ | ||
public task = (task: Omit<ITenDITaskRequest, "type" | "class">) => task | ||
|
||
/** | ||
* Creates a TenDITask for solving | ||
* @param task {@link task} | ||
* @returns ID of the created task | ||
*/ | ||
public createWithTask = async ( | ||
task: Omit<ITenDITaskRequest, "type" | "class"> | ||
): Promise<number> => { | ||
const data: ITenDITaskRequest = { | ||
type: "CustomTask", | ||
class: "TenDI", | ||
...task, | ||
} | ||
const [userAgentData] = this.isUserAgentTask(data) | ||
return await this._createTask(userAgentData) | ||
} | ||
|
||
/** | ||
* Get task result | ||
* @param taskId Task id which returns from {@link createWithTask} function. | ||
* @returns Returns the solution if captcha is solved, otherwise null | ||
* @also see {@link joinTaskResult} | ||
*/ | ||
public getTaskResult = async (taskId: number) => | ||
this._getTaskResult<ITenDITaskResponse>(taskId) | ||
|
||
/** | ||
* Get task result. This function is waits until task to be solved. | ||
* @param taskId Task id which returns from {@link createWithTask} function. | ||
* @param timeout (as seconds) Sets the timeout for the current execution of this function. | ||
* @returns Solution of the task | ||
* @throws CapmonsterError, if task can't be solved in maximum time | ||
* @also see {@link getTaskResult} | ||
*/ | ||
public joinTaskResult = async (taskId: number, timeout?: number) => | ||
this._joinTaskResult<ITenDITaskResponse>(taskId, timeout) | ||
} | ||
|
||
interface ITenDITaskRequest extends ITask { | ||
type: "CustomTask" | ||
class: "TenDI" | ||
/** | ||
* Address of the main page where the captcha is solved. | ||
*/ | ||
websiteURL: string | ||
/** | ||
* captchaAppId. For example "websiteKey": "189123456" - is a unique parameter for your site. | ||
* You can take it from an html page with a captcha or from traffic (see description below). | ||
*/ | ||
websiteKey: string | ||
} | ||
|
||
interface ITenDITaskResponse extends ITaskSolution { | ||
data: ITenDITaskResponseData | ||
headers: Record<string, string> | ||
} | ||
|
||
interface ITenDITaskResponseData { | ||
randstr: string | ||
ticket: string | ||
} |