| const openApiSpec = { | |
| openapi: "3.0.3", | |
| info: { | |
| title: "CF Bypass Solver API", | |
| description: "API for solving Cloudflare challenges including Turnstile captchas, WAF sessions, and proxy requests.", | |
| version: "1.0.0" | |
| }, | |
| servers: [ | |
| { | |
| url: "/", | |
| description: "Current server" | |
| } | |
| ], | |
| paths: { | |
| "/solver": { | |
| get: { | |
| summary: "Solver endpoint (GET)", | |
| description: "Handle solver requests via GET method. The mode parameter determines which solver to use.", | |
| parameters: [ | |
| { $ref: "#/components/parameters/mode" }, | |
| { $ref: "#/components/parameters/url" }, | |
| { $ref: "#/components/parameters/authToken" }, | |
| { $ref: "#/components/parameters/siteKey" } | |
| ], | |
| responses: { | |
| 200: { $ref: "#/components/responses/SuccessResponse" }, | |
| 400: { $ref: "#/components/responses/BadRequest" }, | |
| 401: { $ref: "#/components/responses/Unauthorized" }, | |
| 429: { $ref: "#/components/responses/TooManyRequests" }, | |
| 500: { $ref: "#/components/responses/ServerError" } | |
| } | |
| }, | |
| post: { | |
| summary: "Solver endpoint (POST)", | |
| description: "Handle solver requests via POST method. The mode parameter determines which solver to use.", | |
| requestBody: { | |
| required: true, | |
| content: { | |
| "application/json": { | |
| schema: { $ref: "#/components/schemas/SolverRequest" } | |
| } | |
| } | |
| }, | |
| responses: { | |
| 200: { $ref: "#/components/responses/SuccessResponse" }, | |
| 400: { $ref: "#/components/responses/BadRequest" }, | |
| 401: { $ref: "#/components/responses/Unauthorized" }, | |
| 429: { $ref: "#/components/responses/TooManyRequests" }, | |
| 500: { $ref: "#/components/responses/ServerError" } | |
| } | |
| } | |
| }, | |
| "/api-docs": { | |
| get: { | |
| summary: "OpenAPI Documentation UI", | |
| description: "Interactive Swagger UI documentation for the API.", | |
| responses: { | |
| 200: { | |
| description: "HTML page with Swagger UI" | |
| } | |
| } | |
| } | |
| }, | |
| "/api-docs.json": { | |
| get: { | |
| summary: "OpenAPI JSON Specification", | |
| description: "Returns the raw OpenAPI specification in JSON format.", | |
| responses: { | |
| 200: { | |
| description: "OpenAPI specification", | |
| content: { | |
| "application/json": { | |
| schema: { | |
| type: "object" | |
| } | |
| } | |
| } | |
| } | |
| } | |
| } | |
| } | |
| }, | |
| components: { | |
| parameters: { | |
| mode: { | |
| name: "mode", | |
| in: "query", | |
| required: true, | |
| description: "The solver mode to use", | |
| schema: { | |
| type: "string", | |
| enum: ["source", "turnstile-min", "turnstile-max", "waf-session", "proxy-request"] | |
| } | |
| }, | |
| url: { | |
| name: "url", | |
| in: "query", | |
| required: true, | |
| description: "Target URL to process", | |
| schema: { | |
| type: "string", | |
| format: "uri" | |
| } | |
| }, | |
| authToken: { | |
| name: "authToken", | |
| in: "query", | |
| required: false, | |
| description: "Authentication token (required if server has authToken configured)", | |
| schema: { | |
| type: "string" | |
| } | |
| }, | |
| siteKey: { | |
| name: "siteKey", | |
| in: "query", | |
| required: false, | |
| description: "Turnstile site key (required for turnstile modes)", | |
| schema: { | |
| type: "string" | |
| } | |
| } | |
| }, | |
| schemas: { | |
| SolverRequest: { | |
| type: "object", | |
| required: ["mode", "url"], | |
| properties: { | |
| mode: { | |
| type: "string", | |
| enum: ["source", "turnstile-min", "turnstile-max", "waf-session", "proxy-request"], | |
| description: "The solver mode to use" | |
| }, | |
| url: { | |
| type: "string", | |
| format: "uri", | |
| description: "Target URL to process" | |
| }, | |
| authToken: { | |
| type: "string", | |
| description: "Authentication token (required if server has authToken configured)" | |
| }, | |
| siteKey: { | |
| type: "string", | |
| description: "Turnstile site key (required for turnstile modes)" | |
| }, | |
| proxy: { | |
| type: "object", | |
| description: "Proxy configuration", | |
| properties: { | |
| host: { type: "string", description: "Proxy host" }, | |
| port: { type: "integer", description: "Proxy port" }, | |
| username: { type: "string", description: "Proxy username" }, | |
| password: { type: "string", description: "Proxy password" } | |
| } | |
| }, | |
| method: { | |
| type: "string", | |
| enum: ["GET", "POST", "PUT", "PATCH", "DELETE", "HEAD", "OPTIONS"], | |
| description: "HTTP method for proxy-request mode" | |
| }, | |
| body: { | |
| oneOf: [ | |
| { type: "string" }, | |
| { type: "object" } | |
| ], | |
| description: "Request body for proxy-request mode" | |
| }, | |
| headers: { | |
| type: "object", | |
| description: "Custom headers for the request" | |
| }, | |
| cookies: { | |
| type: "array", | |
| description: "Cookies to set for the request", | |
| items: { | |
| type: "object", | |
| required: ["name", "value"], | |
| properties: { | |
| name: { type: "string" }, | |
| value: { type: "string" }, | |
| domain: { type: "string" }, | |
| path: { type: "string" }, | |
| secure: { type: "boolean" }, | |
| httpOnly: { type: "boolean" }, | |
| sameSite: { type: "string" } | |
| } | |
| } | |
| }, | |
| sessionHeaders: { | |
| type: "object", | |
| description: "Session headers for waf-session mode" | |
| } | |
| } | |
| }, | |
| SourceResponse: { | |
| type: "object", | |
| properties: { | |
| code: { type: "integer", example: 200 }, | |
| source: { type: "string", description: "Page source HTML" } | |
| } | |
| }, | |
| TurnstileResponse: { | |
| type: "object", | |
| properties: { | |
| code: { type: "integer", example: 200 }, | |
| token: { type: "string", description: "Solved Turnstile token" } | |
| } | |
| }, | |
| WafSessionResponse: { | |
| type: "object", | |
| properties: { | |
| code: { type: "integer", example: 200 }, | |
| cookies: { type: "array", items: { type: "object" } }, | |
| headers: { type: "object" } | |
| } | |
| }, | |
| ProxyRequestResponse: { | |
| type: "object", | |
| properties: { | |
| code: { type: "integer", example: 200 }, | |
| status: { type: "integer" }, | |
| headers: { type: "object" }, | |
| body: { type: "string" } | |
| } | |
| }, | |
| ErrorResponse: { | |
| type: "object", | |
| properties: { | |
| code: { type: "integer" }, | |
| message: { type: "string" } | |
| } | |
| } | |
| }, | |
| responses: { | |
| SuccessResponse: { | |
| description: "Successful response. Content varies based on mode used.", | |
| content: { | |
| "application/json": { | |
| schema: { | |
| oneOf: [ | |
| { $ref: "#/components/schemas/SourceResponse" }, | |
| { $ref: "#/components/schemas/TurnstileResponse" }, | |
| { $ref: "#/components/schemas/WafSessionResponse" }, | |
| { $ref: "#/components/schemas/ProxyRequestResponse" } | |
| ] | |
| } | |
| } | |
| } | |
| }, | |
| BadRequest: { | |
| description: "Invalid request parameters", | |
| content: { | |
| "application/json": { | |
| schema: { | |
| type: "object", | |
| properties: { | |
| code: { type: "integer", example: 400 }, | |
| message: { type: "string", example: "Bad Request" }, | |
| schema: { type: "array", items: { type: "object" } } | |
| } | |
| } | |
| } | |
| } | |
| }, | |
| Unauthorized: { | |
| description: "Invalid or missing authentication token", | |
| content: { | |
| "application/json": { | |
| schema: { $ref: "#/components/schemas/ErrorResponse" }, | |
| example: { code: 401, message: "Unauthorized" } | |
| } | |
| } | |
| }, | |
| TooManyRequests: { | |
| description: "Browser limit reached", | |
| content: { | |
| "application/json": { | |
| schema: { $ref: "#/components/schemas/ErrorResponse" }, | |
| example: { code: 429, message: "Too Many Requests" } | |
| } | |
| } | |
| }, | |
| ServerError: { | |
| description: "Internal server error", | |
| content: { | |
| "application/json": { | |
| schema: { $ref: "#/components/schemas/ErrorResponse" }, | |
| example: { code: 500, message: "Error message" } | |
| } | |
| } | |
| } | |
| } | |
| } | |
| }; | |
| module.exports = openApiSpec; | |