Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion nodes/CapmonsterCloud/CapmonsterCloud.node.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"nodeVersion": "1.0",
"codexVersion": "1.0",
"categories": ["Development", "Automation"],
"details": "Solve various CAPTCHA types using CapMonster Cloud.\n\nSupported CAPTCHA types:\n\n• reCAPTCHA V2 / V2 Enterprise\n• reCAPTCHA V3 / V3 Enterprise\n• Cloudflare Turnstile\n• GeeTest (V3 / V4)\n• FunCaptcha (Arkose Labs)\n• DataDome\n• Imperva\n• Amazon WAF\n• Binance\n• Basilisk\n• TenDI\n• Altcha\n• Yidun\n• Prosopo\n• MTCaptcha\n• Castle\n• TSPD\n• Hunt\n\nYou can also provide custom JSON tasks for advanced use cases.",
"resources": {
"primaryDocumentation": [
{
Expand Down
18 changes: 8 additions & 10 deletions nodes/CapmonsterCloud/CapmonsterCloud.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@ import {
INodeTypeDescription,
NodeOperationError,
IDataObject,
NodeApiError,
JsonObject,
NodeConnectionTypes,
} from 'n8n-workflow';

import { request, waitForResult } from './transport/request';
import { TaskType } from './types';
import { softId } from './const';
import { taskBuilders } from './taskBuilder';
import { allFields } from './fields';

Expand All @@ -31,9 +33,10 @@ export class CapmonsterCloud implements INodeType {
group: ['transform'],
version: 1,
description: 'Node for solving CAPTCHAs via CapMonsterCloud service.',
subtitle: '={{$parameter["operation"]}}',
defaults: { name: 'CapMonster Cloud' },
inputs: ['main'],
outputs: ['main'],
inputs: [NodeConnectionTypes.Main],
outputs: [NodeConnectionTypes.Main],
credentials: [
{
name: 'capmonsterCloudApi',
Expand All @@ -50,9 +53,6 @@ export class CapmonsterCloud implements INodeType {

for (let i = 0; i < items.length; i++) {
try {
const credentials = await this.getCredentials('capmonsterCloudApi');
const apiKey = credentials.apiKey as string;

const operation = this.getNodeParameter('operation', i) as TaskType;

let task: IDataObject;
Expand Down Expand Up @@ -90,9 +90,7 @@ export class CapmonsterCloud implements INodeType {
);

const createTask = (await request(this, 'https://api.capmonster.cloud/createTask', {
clientKey: apiKey,
task,
softId,
})) as CreateTaskResponse;

if (createTask.errorId !== 0) {
Expand All @@ -103,7 +101,7 @@ export class CapmonsterCloud implements INodeType {
);
}

const solution = await waitForResult(this, apiKey, createTask.taskId);
const solution = await waitForResult(this, createTask.taskId);

returnData.push({
json: solution,
Expand All @@ -118,7 +116,7 @@ export class CapmonsterCloud implements INodeType {
continue;
}

throw new NodeOperationError(this.getNode(), error as Error, {
throw new NodeApiError(this.getNode(), error as JsonObject, {
itemIndex: i,
});
}
Expand Down
6 changes: 3 additions & 3 deletions nodes/CapmonsterCloud/captchas/geeTestV4.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export const geeTestV4Fields: INodeProperties[] = [
required: true,
displayOptions: { show: { operation: ['geeTestV4'] } },
default: '',
description: 'Whether Address of the page on which the captcha is solved',
description: 'Address of the page on which the captcha is solved',
},
{
displayName: 'GT',
Expand All @@ -19,7 +19,7 @@ export const geeTestV4Fields: INodeProperties[] = [
required: true,
displayOptions: { show: { operation: ['geeTestV4'] } },
default: '',
description: 'Whether The GeeTest identifier key for the domain - the captcha_id parameter',
description: 'GeeTest identifier key for the domain (captcha_id parameter)',
},
{
displayName: 'Geetest API Subdomain',
Expand Down Expand Up @@ -54,7 +54,7 @@ export const geeTestV4Fields: INodeProperties[] = [
type: 'string',
displayOptions: { show: { operation: ['geeTestV4'] } },
default: defaultUserAgent,
description: 'Whether Browser User-Agent used to recognize captcha',
description: 'Browser User-Agent used to recognize captcha',
},
];

Expand Down
48 changes: 24 additions & 24 deletions nodes/CapmonsterCloud/fields.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { recaptchaV2Fields } from './captchas/recaptchaV2';
import { jsonTaskFields } from './captchas/json';
import { recaptchaV3 } from './captchas/recaptchaV3';
import { imageToText } from './captchas/imageToText';
import { INodeProperties } from 'n8n-workflow/dist/esm/interfaces';
import { INodeProperties } from 'n8n-workflow';
import { proxyFields } from './proxy';
import { recaptchaV3Enterprise } from './captchas/recaptchaV3Enterprise';
import { recaptchaV2Enterprise } from './captchas/recaptchaV2Enterprise';
Expand Down Expand Up @@ -35,37 +35,37 @@ import { TaskType } from './types';


const options: Array<{ name: string; value: TaskType }> = [
{ name: 'JSON (Custom Task)', value: 'json' },
{ name: 'Recaptcha V2 Enterprise', value: 'recaptchaV2Enterprise' },
{ name: 'Recaptcha V3 Enterprise', value: 'recaptchaV3Enterprise' },
{ name: 'Recaptcha V2', value: 'recaptchaV2' },
{ name: 'Recaptcha V3', value: 'recaptchaV3' },
{ name: 'Image To Text', value: 'imageToText' },
{ name: 'Recaptcha (Click)', value: 'recaptchaClick' },
{ name: 'Gee Test V3', value: 'geeTestV3' },
{ name: 'Gee Test V4', value: 'geeTestV4' },
{ name: 'Cloudflare Turnstile', value: 'turnstile' },
{ name: 'Cloudflare Challenge (Token)', value: 'turnstileChallengeToken' },
{ name: 'Altcha', value: 'altcha' },
{ name: 'Amazon Full Challenge', value: 'amazonFullChallenge' },
{ name: 'Amazon Invisible Challenge', value: 'amazonInvisibleChallenge' },
{ name: 'Amazon JS API', value: 'amazonJsApi' },
{ name: 'Basilisk', value: 'basilisk' },
{ name: 'Binance', value: 'binance' },
{ name: 'Castle', value: 'castle' },
{ name: 'Cloudflare Challenge (CfClearance)', value: 'turnstileChallengeCfClearance' },
{ name: 'Cloudflare Challenge (Token)', value: 'turnstileChallengeToken' },
{ name: 'Cloudflare Turnstile', value: 'turnstile' },
{ name: 'Cloudflare Waiting Room', value: 'turnstileWaitRoom' },
{ name: 'Complex Image Recognition', value: 'complexImageRecognition' },
{ name: 'DataDome', value: 'datadome' },
{ name: 'Basilisk', value: 'basilisk' },
{ name: 'Tendi', value: 'tendi' },
{ name: 'Binance', value: 'binance' },
{ name: 'FunCaptcha', value: 'funcaptcha' },
{ name: 'Gee Test V3', value: 'geeTestV3' },
{ name: 'Gee Test V4', value: 'geeTestV4' },
{ name: 'Hunt', value: 'hunt' },
{ name: 'Image To Text', value: 'imageToText' },
{ name: 'Imperva', value: 'imperva' },
{ name: 'Amazon JS API', value: 'amazonJsApi' },
{ name: 'Amazon Invisible Challenge', value: 'amazonInvisibleChallenge' },
{ name: 'Amazon Full Challenge', value: 'amazonFullChallenge' },
{ name: 'JSON (Custom Task)', value: 'json' },
{ name: 'Mtcaptcha', value: 'mtcaptcha' },
{ name: 'Prosopo', value: 'prosopo' },
{ name: 'Recaptcha (Click)', value: 'recaptchaClick' },
{ name: 'Recaptcha V2', value: 'recaptchaV2' },
{ name: 'Recaptcha V2 Enterprise', value: 'recaptchaV2Enterprise' },
{ name: 'Recaptcha V3', value: 'recaptchaV3' },
{ name: 'Recaptcha V3 Enterprise', value: 'recaptchaV3Enterprise' },
{ name: 'Temu', value: 'temu' },
{ name: 'Yidun', value: 'yidun' },
{ name: 'Mtcaptcha', value: 'mtcaptcha' },
{ name: 'Altcha', value: 'altcha' },
{ name: 'FunCaptcha', value: 'funcaptcha' },
{ name: 'Castle', value: 'castle' },
{ name: 'Tendi', value: 'tendi' },
{ name: 'Tspd', value: 'tspd' },
{ name: 'Hunt', value: 'hunt' },
{ name: 'Yidun', value: 'yidun' },
];

export const allFields: INodeProperties[] = [
Expand Down
6 changes: 1 addition & 5 deletions nodes/CapmonsterCloud/transport/request.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import { IExecuteFunctions, IDataObject, NodeOperationError, sleep } from 'n8n-workflow';
import { softId } from '../const';

export const request = async (
context: IExecuteFunctions,
url: string,
body: Record<string, unknown>,
) => {
return context.helpers.httpRequest({
return context.helpers.httpRequestWithAuthentication.call(context, 'capmonsterCloudApi', {
method: 'POST',
url,
body,
Expand All @@ -16,16 +15,13 @@ export const request = async (

export const waitForResult = async (
context: IExecuteFunctions,
apiKey: string,
taskId: number,
maxAttempts = 180,
delay = 1000,
): Promise<IDataObject> => {
for (let attempt = 1; attempt <= maxAttempts; attempt++) {
const result = await request(context, 'https://api.capmonster.cloud/getTaskResult', {
clientKey: apiKey,
taskId,
softId,
});

if (result.errorId !== 0) {
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@zennolab_com/n8n-nodes-capmonstercloud",
"version": "0.0.6",
"version": "0.0.7",
"publishConfig": {
"access": "public"
},
Expand Down
Loading