Skip to content

Commit

Permalink
feat: added TenDI task
Browse files Browse the repository at this point in the history
  • Loading branch information
alperensert committed Apr 17, 2024
1 parent 9bdf4ee commit 6236065
Show file tree
Hide file tree
Showing 2 changed files with 86 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/index.ts
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"
79 changes: 79 additions & 0 deletions src/tasks/tendi.ts
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
}

0 comments on commit 6236065

Please sign in to comment.