diff --git a/package.json b/package.json index 5167c16..74e168e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "2captcha", - "version": "4.0.0@next", + "version": "4.0.0", "description": "An asynchronous wrapper around the 2captcha API.", "main": "dist/index.js", "repository": "https://github.com/furry/2captcha", diff --git a/src/structs/solver.ts b/src/structs/solver.ts index 7dfc739..14a08fd 100644 --- a/src/structs/solver.ts +++ b/src/structs/solver.ts @@ -34,6 +34,7 @@ import { Task, TurnstileDefault, TurnstileResult, + GeetestV4Result, } from "../types.js"; import { toBase64, toQueryString } from "../utils/conversions.js"; @@ -475,6 +476,31 @@ export class Solver { return this.registerPollEntry(cid); } + + /** + * Solves a GeeTest v4 captcha + * @param pageurl The URL of the page the captcha appears on. + * @param proxied Whether to use a user provied proxy to solve this captcha. + * @param extra Any extra parameters to send to the solver. + * @throws {SolverError} + * @returns {Promise>} + */ + public async geetestV4( + pageurl: string, proxied: T = false as T, + extra: T extends false ? GeetestExtrasV4 : GeetestExtrasV4 | ProxiedCaptchaExtras + ): Promise> { + const cid = await this.newTask({ + task: { + type: proxied ? "GeeTestTask" : "GeeTestTaskProxyless", + websiteURL: pageurl, + version: 4, + ...extra + } + }) + + return this.registerPollEntry(cid); + } + /** * Solves a GeeTest captcha. * @param pageurl URL of the page the captcha appears on. @@ -485,7 +511,10 @@ export class Solver { * @throws {SolverError} * @returns {Promise>} */ - public async geetest(pageurl: string, gt: string, challenge: string, proxied = false, extra: GeetestExtrasV3 | GeetestExtrasV4): Promise> { + public async geetest( + pageurl: string, gt: string, challenge: string, + proxied: T = false as T, + extra: T extends false ? GeetestExtrasV3 : GeetestExtrasV3 | ProxiedCaptchaExtras): Promise> { const cid = await this.newTask({ task: { type: proxied ? "GeeTestTask" : "GeeTestTaskProxyless", diff --git a/src/types.ts b/src/types.ts index 0355b22..6ea7b83 100644 --- a/src/types.ts +++ b/src/types.ts @@ -174,7 +174,6 @@ export interface TurnstileExtras { } export interface GeetestExtrasV4 { - version: 4 initParameters?: { captcha_id: string } @@ -183,7 +182,6 @@ export interface GeetestExtrasV4 { export interface GeetestExtrasV3 { geetestApiServerSubdomain: string, useragent: string, - version: 3 }