mtcrackcha
Version:
a free, working, and open-source mtcaptcha solving library
143 lines (139 loc) • 3.98 kB
TypeScript
// Generated by dts-bundle-generator v9.5.1
export interface MTCaptchaBase {
ct: string;
hasFoldChlg: boolean;
foldChlg: {
fseed: string;
fslots: number;
fdepth: number;
};
}
export interface MTCaptchaTextChallenge extends MTCaptchaBase {
hasTextChlg: true;
textChlg: {
textlen: number;
};
}
export interface MTCaptchaInvisibleChallenge extends MTCaptchaBase {
hasTextChlg: false;
}
export type MTCaptchaChallenge1 = MTCaptchaTextChallenge | MTCaptchaInvisibleChallenge;
export interface MTCaptchaWaitChallenge extends MTCaptchaBase {
hasWaitChlg: true;
waitChlg: {
time: string;
};
}
export interface MTCaptchaNoWaitChallenge extends MTCaptchaBase {
hasWaitChlg: false;
}
export type MTCaptchaChallenge2 = MTCaptchaWaitChallenge | MTCaptchaNoWaitChallenge;
export type MTCaptchaChallenge = MTCaptchaChallenge1 & MTCaptchaChallenge2;
export interface ImageResult {
result: {
img: {
image64: string;
};
};
[key: string]: any;
}
export interface VerifyResult {
result: {
verifyResult?: {
isVerified: boolean;
verifiedToken: {
vt: string;
};
};
};
[key: string]: any;
}
export interface SolveResult {
success: boolean;
tries: number;
token?: string;
error?: string;
rawResponse?: any;
}
export interface MTCaptchaParamsBase {
siteKey: string;
testKey?: string;
host: string;
}
export interface MTCaptchaParamsText extends MTCaptchaParamsBase {
mistralKey?: string;
}
export interface MTCaptchaParamsInvisible extends MTCaptchaParamsBase {
invisible: true;
}
export type MTCaptchaParams = MTCaptchaParamsText | MTCaptchaParamsInvisible;
declare class MTCaptcha {
baseHeaders: {
accept: string;
"accept-encoding": string;
"accept-language": string;
"content-type": string;
referer: string;
"sec-ch-ua": string;
"sec-ch-ua-mobile": string;
"sec-ch-ua-platform": string;
"sec-fetch-dest": string;
"sec-fetch-mode": string;
"sec-fetch-site": string;
"user-agent": string;
};
siteKey: string;
testKey: string;
host: string;
mistralKey?: string;
invisible?: boolean;
visitorId: string;
/**
* Creates an instance of MTCaptcha.
* @param config - Configuration object for MTCaptcha.
* @param config.siteKey - The site key for the captcha.
* @param config.testKey - (optional) The test key for the captcha.
* @param config.host - The host of the captcha.
* @param config.mistralKey - (optional) A Mistral API key for solving text challenges.
* @param config.invisible - (optional) Whether the captcha is invisible.
*/
constructor(config: MTCaptchaParams);
/**
* Grabs a captcha challenge from MTCaptcha.
* @param act - The action parameter to be sent with the request, default is '$'.
* @returns The captcha challenge.
*/
getChallenge(act: string): Promise<MTCaptchaChallenge>;
/**
* Fetches the image associated with a challenge.
* @param chlg - The challenge for which to fetch the image.
* @returns The image result.
*/
getImage(chlg: MTCaptchaChallenge): Promise<ImageResult>;
/**
* Asks Mistral for the solution to the provided captcha image.
* @param image64 - The base64-encoded image of the captcha challenge.
* @returns The captcha solution, per Mistral.
*/
askAI(image64: string, numLetters: number): Promise<{
solution: string;
}>;
/**
* Verifies a solution to a challenge.
* @param chlg - The captcha challenge being solved.
* @param solution - The provided solution to the challenge.
* @param act - The action parameter to be sent with the request.
* @returns The result of solution and verification token (if successful).
*/
verify(chlg: MTCaptchaChallenge, solution: string, act: string): Promise<VerifyResult>;
/**
* Solves a captcha in its entirety.
* @param act - The action parameter to be sent with the requests.
* @returns The result of solution and verification token (if successful).
*/
solve(act?: string, _tries?: number): Promise<SolveResult>;
}
export {
MTCaptcha as default,
};
export {};