Captcha Solving

OpenSubmitter provdes a proxy layer to Anti-Captcha npm library, which prevents template developer from accessing user's API key. Captcha solving will work only is the user has specified Anti-Captcha's API key in OpenSubmitter's settings and the balance is positive. This example template solves all possible captcha types supported by Anti-Captcha.
Method solveCaptcha provides that proxy layer:

async solveCaptcha(captcha: Captcha): Promise<string | object>

interface Captcha {
    type: CaptchaType,
    imageBodyBase64?: string,   //  for image captcha
    websiteURL?: string,        //  for all JS captchas
    websiteKey?: string,        //  "websiteKey" for Recaptcha, HCaptcha and Turnstile, "gt" and "captchaId" for Geetest, "websitePublicKey" for FunCaptcha
    extraParameters?: ExtraCaptchaParameters    //  any other extra parameters go here

    // If set, captcha will be solved via this proxy.
    // If not set, captcha will be solved without proxy.
    proxyType?: ('http' | 'socks4' | 'socks5'),
    proxyAddress?: string,
    proxyPort?: number,
    proxyLogin?: string,
    proxyPassword?: string
}

type CaptchaType = ('image' | 'RecaptchaV2' | 'RecaptchaV3' | 'HCaptcha' | 'FunCaptcha' | 'Geetest3' | 'Geetest4' | 'Turnstile')

interface ExtraCaptchaParameters {
    userAgent: string,                  //  custom user-agent, required for proxy-on tasks
    v3score?: (0.3 | 0.7 | 0.9)         //  for Recaptcha V3
    pageAction: string | null           //  page action for Recaptcha V3 and Turnstile
    isInvisible?: boolean               //  for Recaptcha V2 and HCaptcha
    recaptchaDataSValue?: string        //  "data-s" value for Recaptcha V2 (google.com domains captcha)
    enterprisePayload?: any             //  custom enterprise payload data for HCaptcha or FunCaptcha
    APISubdomain?: string               //  API subdomain value for FunCaptcha or Geetest
    funcaptchaDataBlob?: string         //  extra token for FunCaptcha
    geetestChallenge?: string           //  challenge token for Geetest
    geetest4InitParameters?: any        //  initialization parameters for Geetest4
}
Examples

Solve image captcha

try {
    const pathToImage = '/path/captcha.png'
    const textResult = await this.solveCaptcha({
        type: 'image',
        imageBodyBase64: fs.readFileSync(pathToImage, { encoding: 'base64' })
    })
} catch (e) {
    this.log("could not solve captcha: "+e.toString())
}

Solve Recaptcha V2

try {
    const token = await this.solveCaptcha({
        type: 'RecaptchaV2',
        websiteURL: 'https://www.website.com/',
        websiteKey: 'SITEKEY_HERE'
        // extraParameters: {
        //     isInvisible: true                   // Use this for Recaptcha V2-invisible
        //     recaptchaDataSValue:  "token_here"  // Use this to provide data-s value for Google.com domains
        // }
    })
} catch (e) {
    this.log("could not solve captcha: "+e.toString())
}

Solve Recaptcha V3

try {
    const token = await this.solveCaptcha({
        type: 'RecaptchaV3',
        websiteURL: 'https://www.website.com/',
        websiteKey: 'SITEKEY_HERE'
        extraParameters: {
            v3score: 0.7,
            pageAction: 'login'
        }
    })
} catch (e) {
    this.log("could not solve captcha: "+e.toString())
}

Solve HCaptcha

try {
    const { token, userAgent } = await this.solveCaptcha({
        type: 'HCaptcha',
        websiteURL: 'https://www.website.com/',
        websiteKey: 'SITEKEY_HERE'
        // extraParameters: {
        //     isInvisible: true                   // Use this for invisible HCaptcha
        // },
        // If you'd like to solve via a proxy, just uncomment this:
        // proxyType: 'http',
        // proxyAddress: '1.2.3.4',
        // proxyPort: 8080,
        // proxyLogin: "login",
        // proxyPassword: "password"
    })
} catch (e) {
    this.log("could not solve captcha: "+e.toString())
}

Solve Funcaptcha

try {
    const token = await this.solveCaptcha({
        type: 'FunCaptcha',
        websiteURL: 'https://www.website.com/',
        websiteKey: 'PUBLIC_KEY_HERE'
        extraParameters: {
            funcaptchaDataBlob: "{'blob':'some value'}",
            APISubdomain: 'client-api.arkoselabs.com'
        },
        // If you'd like to solve via a proxy, just uncomment this:
        // proxyType: 'http',
        // proxyAddress: '1.2.3.4',
        // proxyPort: 8080,
        // proxyLogin: "login",
        // proxyPassword: "password"
    })
} catch (e) {
    this.log("could not solve captcha: "+e.toString())
}

Solve Geetest version 3

try {
    const token = await this.solveCaptcha({
        type: 'Geetest3',
        websiteURL: 'https://www.website.com/',
        websiteKey: 'GT_KEY_HERE'
        extraParameters: {
            geetestChallenge: "ONE_TIME_CHALLENGE_CODE_HERE"
        },
        // If you'd like to solve via a proxy, just uncomment this:
        // proxyType: 'http',
        // proxyAddress: '1.2.3.4',
        // proxyPort: 8080,
        // proxyLogin: "login",
        // proxyPassword: "password"
    })
} catch (e) {
    this.log("could not solve captcha: "+e.toString())
}

Solve Geetest version 4

try {
    const token = await this.solveCaptcha({
        type: 'Geetest4',
        websiteURL: 'https://www.website.com/',
        websiteKey: 'CAPTCHA_ID_HERE'
        extraParameters: {
            geetest4InitParameters: {
                "riskType": "slide"
            }
        },
        // If you'd like to solve via a proxy, just uncomment this:
        // proxyType: 'http',
        // proxyAddress: '1.2.3.4',
        // proxyPort: 8080,
        // proxyLogin: "login",
        // proxyPassword: "password"
    })
} catch (e) {
    this.log("could not solve captcha: "+e.toString())
}

Solve Turnstile

try {
    const token = await this.solveCaptcha({
        type: 'Turnstile',
        websiteURL: 'https://www.website.com/',
        websiteKey: 'SITEKEY_HERE'
        extraParameters: {
            pageAction: 'optional_page_action'
        },
        // If you'd like to solve via a proxy, just uncomment this:
        // proxyType: 'http',
        // proxyAddress: '1.2.3.4',
        // proxyPort: 8080,
        // proxyLogin: "login",
        // proxyPassword: "password"
    })
} catch (e) {
    this.log("could not solve captcha: "+e.toString())
}