@intuned/runtime-dev 1.3.15-hook.0 → 1.3.15-ts-helpers

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,29 +1,29 @@
1
1
  import { Command } from "commander";
2
2
  export declare const baseRunAuthSessionCommandOptionsSchema: import("zod").ZodObject<{
3
3
  proxy: import("zod").ZodOptional<import("zod").ZodString>;
4
- headless: import("zod").ZodDefault<import("zod").ZodBoolean>;
4
+ trace: import("zod").ZodDefault<import("zod").ZodBoolean>;
5
5
  timeout: import("zod").ZodEffects<import("zod").ZodEffects<import("zod").ZodDefault<import("zod").ZodString>, import("ms").StringValue, string | undefined>, number, string | undefined>;
6
+ headless: import("zod").ZodDefault<import("zod").ZodBoolean>;
6
7
  keepBrowserOpen: import("zod").ZodDefault<import("zod").ZodBoolean>;
7
8
  cdpUrl: import("zod").ZodOptional<import("zod").ZodString>;
8
- trace: import("zod").ZodDefault<import("zod").ZodBoolean>;
9
9
  checkAttempts: import("zod").ZodDefault<import("zod").ZodNumber>;
10
10
  createAttempts: import("zod").ZodDefault<import("zod").ZodNumber>;
11
11
  }, "strip", import("zod").ZodTypeAny, {
12
- headless: boolean;
12
+ trace: boolean;
13
13
  timeout: number;
14
+ headless: boolean;
14
15
  keepBrowserOpen: boolean;
15
- trace: boolean;
16
16
  checkAttempts: number;
17
17
  createAttempts: number;
18
18
  proxy?: string | undefined;
19
19
  cdpUrl?: string | undefined;
20
20
  }, {
21
21
  proxy?: string | undefined;
22
- headless?: boolean | undefined;
22
+ trace?: boolean | undefined;
23
23
  timeout?: string | undefined;
24
+ headless?: boolean | undefined;
24
25
  keepBrowserOpen?: boolean | undefined;
25
26
  cdpUrl?: string | undefined;
26
- trace?: boolean | undefined;
27
27
  checkAttempts?: number | undefined;
28
28
  createAttempts?: number | undefined;
29
29
  }>;
@@ -17,10 +17,10 @@ export declare const baseCommandOptionsSchema: z.ZodObject<{
17
17
  keepBrowserOpen: z.ZodDefault<z.ZodBoolean>;
18
18
  cdpUrl: z.ZodOptional<z.ZodString>;
19
19
  }, "strip", z.ZodTypeAny, {
20
- headless: boolean;
20
+ trace: boolean;
21
21
  timeout: number;
22
+ headless: boolean;
22
23
  keepBrowserOpen: boolean;
23
- trace: boolean;
24
24
  proxy?: string | undefined;
25
25
  cdpUrl?: string | undefined;
26
26
  }, {
@@ -18,8 +18,8 @@ export declare function executeRunCreateAuthSessionCLI({ id, input, checkRetries
18
18
  cookies: {
19
19
  path: string;
20
20
  value: string;
21
- name: string;
22
21
  domain: string;
22
+ name: string;
23
23
  expires: number;
24
24
  httpOnly: boolean;
25
25
  secure: boolean;
@@ -49,8 +49,8 @@ export declare function executeRunUpdateAuthSessionCLI({ id, input, checkRetries
49
49
  cookies: {
50
50
  path: string;
51
51
  value: string;
52
- name: string;
53
52
  domain: string;
53
+ name: string;
54
54
  expires: number;
55
55
  httpOnly: boolean;
56
56
  secure: boolean;
@@ -78,8 +78,8 @@ export declare function executeAttemptCreateAuthSessionCLI({ id, input, ...rest
78
78
  cookies: {
79
79
  path: string;
80
80
  value: string;
81
- name: string;
82
81
  domain: string;
82
+ name: string;
83
83
  expires: number;
84
84
  httpOnly: boolean;
85
85
  secure: boolean;
@@ -106,8 +106,8 @@ export declare function executeAttemptCheckAuthSessionCLI({ id, ...rest }: {
106
106
  cookies: {
107
107
  path: string;
108
108
  value: string;
109
- name: string;
110
109
  domain: string;
110
+ name: string;
111
111
  expires: number;
112
112
  httpOnly: boolean;
113
113
  secure: boolean;
@@ -140,8 +140,8 @@ declare function runCreate({ authSessionInput, proxy, headless, timeout, traceId
140
140
  cookies: {
141
141
  path: string;
142
142
  value: string;
143
- name: string;
144
143
  domain: string;
144
+ name: string;
145
145
  expires: number;
146
146
  httpOnly: boolean;
147
147
  secure: boolean;
@@ -177,8 +177,8 @@ declare function runCreateWithRetries({ authSessionId, authSessionInput, retries
177
177
  cookies: {
178
178
  path: string;
179
179
  value: string;
180
- name: string;
181
180
  domain: string;
181
+ name: string;
182
182
  expires: number;
183
183
  httpOnly: boolean;
184
184
  secure: boolean;
@@ -8,8 +8,8 @@ export declare function loadAuthSessionInstance(authSessionId: string): Promise<
8
8
  cookies: {
9
9
  path: string;
10
10
  value: string;
11
- name: string;
12
11
  domain: string;
12
+ name: string;
13
13
  expires: number;
14
14
  httpOnly: boolean;
15
15
  secure: boolean;
@@ -1,5 +1,5 @@
1
1
  import * as playwright from "playwright";
2
- import { CaptchaSolverSettingsWithRunContext } from "./settingsSchema";
2
+ import { CaptchaSolverSettingsWithRunContext } from "../settingsSchema";
3
3
  export declare function buildExtensionsList(): string[];
4
4
  export declare function getIntunedExtensionPath(): string;
5
5
  export declare function isIntunedExtensionEnabled(): boolean;
@@ -9,15 +9,27 @@ exports.getIntunedExtensionSettings = getIntunedExtensionSettings;
9
9
  exports.getIntunedExtensionWorker = getIntunedExtensionWorker;
10
10
  exports.isIntunedExtensionEnabled = isIntunedExtensionEnabled;
11
11
  exports.setupIntunedExtension = setupIntunedExtension;
12
- var _settings = require("../commands/common/utils/settings");
13
- var _settingsSchema = require("./settingsSchema");
14
- var _constants = require("./constants");
15
- var _jwtTokenManager = require("./jwtTokenManager");
12
+ var _settings = require("../../commands/common/utils/settings");
13
+ var _settingsSchema = require("../settingsSchema");
14
+ var _constants = require("../constants");
15
+ var _jwtTokenManager = require("../jwtTokenManager");
16
16
  var _path = _interopRequireDefault(require("path"));
17
17
  var _promises = require("fs/promises");
18
+ var _intunedExtensionServer = require("./intunedExtensionServer");
19
+ var _portfinder = require("portfinder");
18
20
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
19
21
  const INTUNED_WORKER = "intunedWorker.js";
20
22
  const INTUNED_EXTENSION_SETTINGS_FILE_NAME = "intunedSettings.json";
23
+ const INTUNED_CAPTCHA_EXTENSION_PORT_ENV_VAR = "INTUNED_CAPTCHA_EXTENSION_PORT";
24
+ function getIntunedCaptchaExtensionPortFromEnv() {
25
+ const raw = process.env[INTUNED_CAPTCHA_EXTENSION_PORT_ENV_VAR];
26
+ if (!raw) return null;
27
+ const parsed = Number(raw);
28
+ if (!Number.isFinite(parsed) || parsed <= 0 || parsed > 65535) {
29
+ throw new Error(`Invalid ${INTUNED_CAPTCHA_EXTENSION_PORT_ENV_VAR}: ${raw}`);
30
+ }
31
+ return parsed;
32
+ }
21
33
  function buildExtensionsList() {
22
34
  const extensionsList = [];
23
35
  if (isIntunedExtensionEnabled()) {
@@ -61,12 +73,35 @@ async function getIntunedExtensionSettings() {
61
73
  const missingEnvVars = [domain && "FUNCTIONS_DOMAIN", workspaceId && _constants.WORKSPACE_ID_ENV_VAR_KEY, projectId && `INTUNED_INTEGRATION_ID OR ${_constants.PROJECT_ID_ENV_VAR_KEY}`];
62
74
  throw new Error(`Missing required environment variables: ${missingEnvVars}`);
63
75
  }
76
+ const authentication = (() => {
77
+ if (process.env.INTUNED_API_KEY) {
78
+ return {
79
+ type: "apiKey",
80
+ apiKey: process.env.INTUNED_API_KEY
81
+ };
82
+ }
83
+ if (process.env.INTUNED_BASIC_AUTH_USERNAME && process.env.INTUNED_BASIC_AUTH_PASSWORD) {
84
+ const credentials = `${process.env.INTUNED_BASIC_AUTH_USERNAME}:${process.env.INTUNED_BASIC_AUTH_PASSWORD}`;
85
+ const token = Buffer.from(credentials, "utf-8").toString("base64");
86
+ return {
87
+ type: "basic",
88
+ token
89
+ };
90
+ }
91
+ return {
92
+ type: "bearer",
93
+ token: _jwtTokenManager.backendFunctionsTokenManager.token
94
+ };
95
+ })();
96
+ const baseUrl = process.env.INTUNED_API_BASE_URL ?? domain;
97
+ const port = getIntunedCaptchaExtensionPortFromEnv() ?? (await (0, _portfinder.getPort)({}));
64
98
  return {
65
99
  ...(settings.captchaSolver ?? _settingsSchema.captchaSolverSettingsSchema.parse({})),
66
100
  workspaceId,
67
101
  projectId,
68
- baseUrl: domain,
69
- token: _jwtTokenManager.backendFunctionsTokenManager.token
102
+ baseUrl,
103
+ authentication,
104
+ port
70
105
  };
71
106
  }
72
107
  async function setupIntunedExtension() {
@@ -76,5 +111,11 @@ async function setupIntunedExtension() {
76
111
  const intunedExtensionPath = getIntunedExtensionPath();
77
112
  const intunedExtensionSettingsPath = _path.default.join(intunedExtensionPath, INTUNED_EXTENSION_SETTINGS_FILE_NAME);
78
113
  const settings = await getIntunedExtensionSettings();
114
+ if (!settings.enabled) {
115
+ return;
116
+ }
117
+ await (0, _intunedExtensionServer.setupIntunedExtensionServer)({
118
+ port: settings.port ?? 9000
119
+ });
79
120
  await (0, _promises.writeFile)(intunedExtensionSettingsPath, JSON.stringify(settings));
80
121
  }
@@ -0,0 +1,27 @@
1
+ import type * as playwright from "playwright";
2
+ import { Captcha, CaptchaCallback, CaptchaStatus } from "./types";
3
+ export declare class ExtensionServer {
4
+ private tabs;
5
+ private app;
6
+ isHealthy: boolean;
7
+ constructor();
8
+ private getOrCreateTab;
9
+ handleUpsertCaptcha(captcha: Captcha): Promise<void>;
10
+ start({ port, host, }: {
11
+ port: number;
12
+ host?: string;
13
+ }): Promise<void>;
14
+ stop(): Promise<void>;
15
+ getCaptchas(page: playwright.Page, status?: CaptchaStatus): Promise<Captcha[]>;
16
+ subscribe(page: playwright.Page, handler: CaptchaCallback, status?: CaptchaStatus): Promise<void>;
17
+ unsubscribe(page: playwright.Page, handler: CaptchaCallback, status?: CaptchaStatus): Promise<void>;
18
+ removeTab(tabId: number): void;
19
+ getTabId(page: playwright.Page): Promise<number>;
20
+ }
21
+ export declare function getIntunedExtensionServer(): ExtensionServer;
22
+ export declare function setupIntunedExtensionServer({ port, host, }: {
23
+ port: number;
24
+ host?: string;
25
+ }): Promise<void>;
26
+ export declare function cleanIntunedExtensionServer(): Promise<void>;
27
+ export declare function getTabId(page: playwright.Page): Promise<number>;
@@ -0,0 +1,181 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.ExtensionServer = void 0;
7
+ exports.cleanIntunedExtensionServer = cleanIntunedExtensionServer;
8
+ exports.getIntunedExtensionServer = getIntunedExtensionServer;
9
+ exports.getTabId = getTabId;
10
+ exports.setupIntunedExtensionServer = setupIntunedExtensionServer;
11
+ var _fastify = _interopRequireDefault(require("fastify"));
12
+ var _types = require("./types");
13
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
14
+ class TabCaptchaState {
15
+ constructor(tabId) {
16
+ this.tabId = tabId;
17
+ this.captchasById = new Map();
18
+ this.subscribers = new Array();
19
+ }
20
+ subscribe(handler) {
21
+ this.subscribers.push(handler);
22
+ }
23
+ unsubscribe(handler, status) {
24
+ const index = this.subscribers.findIndex(subscriber => subscriber.handler === handler && (subscriber.status === status || !status));
25
+ if (index !== -1) {
26
+ this.subscribers.splice(index, 1);
27
+ }
28
+ }
29
+ getCaptchas() {
30
+ return [...this.captchasById.values()];
31
+ }
32
+ async upsertCaptcha(captcha) {
33
+ this.captchasById.set(captcha.id, captcha);
34
+ for (const subscriber of this.subscribers) {
35
+ if (!subscriber.status || subscriber.status === captcha.status) {
36
+ await subscriber.handler(captcha);
37
+ }
38
+ }
39
+ }
40
+ }
41
+ class ExtensionServer {
42
+ app = null;
43
+ isHealthy = false;
44
+ constructor() {
45
+ this.tabs = new Map();
46
+ }
47
+ getOrCreateTab(tabId) {
48
+ const existing = this.tabs.get(tabId);
49
+ if (existing) return existing;
50
+ const created = new TabCaptchaState(tabId);
51
+ this.tabs.set(tabId, created);
52
+ return created;
53
+ }
54
+ async handleUpsertCaptcha(captcha) {
55
+ const tab = this.getOrCreateTab(captcha.tabId);
56
+ await tab.upsertCaptcha(captcha);
57
+ }
58
+ async start({
59
+ port,
60
+ host = "0.0.0.0"
61
+ }) {
62
+ if (this.app) {
63
+ return;
64
+ }
65
+ this.app = (0, _fastify.default)({
66
+ logger: false,
67
+ bodyLimit: 1_000_000
68
+ });
69
+ this.app.post("/state", async (request, reply) => {
70
+ try {
71
+ const result = _types.captchaSchema.safeParse(request.body);
72
+ if (!result.success) {
73
+ return reply.code(400).send({
74
+ error: "Invalid captcha payload",
75
+ details: result.error.flatten().fieldErrors
76
+ });
77
+ }
78
+ await this.handleUpsertCaptcha(result.data);
79
+ return reply.code(200).send({});
80
+ } catch (error) {
81
+ console.error("Error processing captcha state update:", error);
82
+ return reply.code(500).send({
83
+ error: "Internal server error",
84
+ message: error?.message ?? String(error)
85
+ });
86
+ }
87
+ });
88
+ this.app.setNotFoundHandler((_request, reply) => {
89
+ return reply.code(404).send({
90
+ error: "Not found"
91
+ });
92
+ });
93
+ await this.app.listen({
94
+ port,
95
+ host
96
+ });
97
+ this.isHealthy = true;
98
+ }
99
+ async stop() {
100
+ if (!this.app) return;
101
+ const toClose = this.app;
102
+ this.app = null;
103
+ this.isHealthy = false;
104
+ await toClose.close();
105
+ }
106
+ async getCaptchas(page, status) {
107
+ const tabId = await getTabId(page);
108
+ const tab = this.tabs.get(tabId);
109
+ if (!tab) return [];
110
+ const captchas = tab.getCaptchas();
111
+ if (!status) return captchas;
112
+ return captchas.filter(c => c.status === status && c.tabId === tabId);
113
+ }
114
+ async subscribe(page, handler, status) {
115
+ const tabId = await getTabId(page);
116
+ const tab = this.getOrCreateTab(tabId);
117
+ tab.subscribe({
118
+ handler,
119
+ status
120
+ });
121
+ }
122
+ async unsubscribe(page, handler, status) {
123
+ const tabId = await getTabId(page);
124
+ const tab = this.tabs.get(tabId);
125
+ if (!tab) return;
126
+ tab.unsubscribe(handler, status);
127
+ }
128
+ removeTab(tabId) {
129
+ this.tabs.delete(tabId);
130
+ }
131
+ async getTabId(page) {
132
+ return await getTabId(page);
133
+ }
134
+ }
135
+ exports.ExtensionServer = ExtensionServer;
136
+ let extensionServerSingleton = null;
137
+ function getIntunedExtensionServer() {
138
+ if (!extensionServerSingleton) {
139
+ throw new Error("Intuned Extension Server is not initialized.");
140
+ }
141
+ return extensionServerSingleton;
142
+ }
143
+ async function setupIntunedExtensionServer({
144
+ port,
145
+ host
146
+ }) {
147
+ if (!extensionServerSingleton) {
148
+ extensionServerSingleton = new ExtensionServer();
149
+ }
150
+ await extensionServerSingleton.start({
151
+ port,
152
+ host
153
+ });
154
+ }
155
+ async function cleanIntunedExtensionServer() {
156
+ if (extensionServerSingleton) {
157
+ await extensionServerSingleton.stop();
158
+ extensionServerSingleton = null;
159
+ }
160
+ }
161
+ const TAB_ID_CACHE_KEY = "__INTUNED_CACHED_TAB_ID__";
162
+ async function getTabId(page) {
163
+ const cached = page[TAB_ID_CACHE_KEY];
164
+ if (cached !== undefined && typeof cached === "number") {
165
+ return cached;
166
+ }
167
+ let tabId;
168
+ try {
169
+ tabId = await page.evaluate("window.__INTUNED_TAB_ID__", {
170
+ timeout: 100
171
+ });
172
+ } catch {
173
+ await page.waitForFunction("window.__INTUNED_TAB_ID__ !== undefined", {
174
+ timeout: 15_000
175
+ });
176
+ tabId = await page.evaluate("window.__INTUNED_TAB_ID__");
177
+ }
178
+ const numericTabId = Number(tabId);
179
+ page[TAB_ID_CACHE_KEY] = numericTabId;
180
+ return numericTabId;
181
+ }
@@ -0,0 +1,212 @@
1
+ import { z } from "zod";
2
+ export declare const captchaTypeSchema: z.ZodEnum<["aws", "cloudflare", "customcaptcha", "funcaptcha", "geetest", "hcaptcha", "lemincaptcha", "recaptcha", "textcaptcha"]>;
3
+ export type CaptchaType = z.infer<typeof captchaTypeSchema>;
4
+ export declare const captchaStatusSchema: z.ZodEnum<["attached", "solving", "solved", "error", "detached"]>;
5
+ export type CaptchaStatus = z.infer<typeof captchaStatusSchema>;
6
+ export declare const captchaErrorCodeSchema: z.ZodEnum<["HIT_LIMIT", "MAX_RETRIES", "UNEXPECTED_SERVER_RESPONSE", "UNEXPECTED_ERROR"]>;
7
+ export type CaptchaErrorCode = z.infer<typeof captchaErrorCodeSchema>;
8
+ export declare const captchaErrorSchema: z.ZodObject<{
9
+ code: z.ZodEnum<["HIT_LIMIT", "MAX_RETRIES", "UNEXPECTED_SERVER_RESPONSE", "UNEXPECTED_ERROR"]>;
10
+ error: z.ZodOptional<z.ZodUnknown>;
11
+ }, "strip", z.ZodTypeAny, {
12
+ code: "HIT_LIMIT" | "MAX_RETRIES" | "UNEXPECTED_SERVER_RESPONSE" | "UNEXPECTED_ERROR";
13
+ error?: unknown;
14
+ }, {
15
+ code: "HIT_LIMIT" | "MAX_RETRIES" | "UNEXPECTED_SERVER_RESPONSE" | "UNEXPECTED_ERROR";
16
+ error?: unknown;
17
+ }>;
18
+ export type CaptchaError = z.infer<typeof captchaErrorSchema>;
19
+ declare const captchaBaseSchema: z.ZodObject<{
20
+ id: z.ZodString;
21
+ tabId: z.ZodNumber;
22
+ type: z.ZodEnum<["aws", "cloudflare", "customcaptcha", "funcaptcha", "geetest", "hcaptcha", "lemincaptcha", "recaptcha", "textcaptcha"]>;
23
+ retryCount: z.ZodOptional<z.ZodNumber>;
24
+ }, "strip", z.ZodTypeAny, {
25
+ type: "aws" | "cloudflare" | "customcaptcha" | "funcaptcha" | "geetest" | "hcaptcha" | "lemincaptcha" | "recaptcha" | "textcaptcha";
26
+ id: string;
27
+ tabId: number;
28
+ retryCount?: number | undefined;
29
+ }, {
30
+ type: "aws" | "cloudflare" | "customcaptcha" | "funcaptcha" | "geetest" | "hcaptcha" | "lemincaptcha" | "recaptcha" | "textcaptcha";
31
+ id: string;
32
+ tabId: number;
33
+ retryCount?: number | undefined;
34
+ }>;
35
+ export type CaptchaBase = z.infer<typeof captchaBaseSchema>;
36
+ declare const captchaNonErrorSchema: z.ZodObject<{
37
+ type: z.ZodEnum<["aws", "cloudflare", "customcaptcha", "funcaptcha", "geetest", "hcaptcha", "lemincaptcha", "recaptcha", "textcaptcha"]>;
38
+ id: z.ZodString;
39
+ tabId: z.ZodNumber;
40
+ retryCount: z.ZodOptional<z.ZodNumber>;
41
+ status: z.ZodEnum<["attached", "solving", "solved", "detached"]>;
42
+ }, "strip", z.ZodTypeAny, {
43
+ type: "aws" | "cloudflare" | "customcaptcha" | "funcaptcha" | "geetest" | "hcaptcha" | "lemincaptcha" | "recaptcha" | "textcaptcha";
44
+ status: "attached" | "solving" | "solved" | "detached";
45
+ id: string;
46
+ tabId: number;
47
+ retryCount?: number | undefined;
48
+ }, {
49
+ type: "aws" | "cloudflare" | "customcaptcha" | "funcaptcha" | "geetest" | "hcaptcha" | "lemincaptcha" | "recaptcha" | "textcaptcha";
50
+ status: "attached" | "solving" | "solved" | "detached";
51
+ id: string;
52
+ tabId: number;
53
+ retryCount?: number | undefined;
54
+ }>;
55
+ export type CaptchaNonError = z.infer<typeof captchaNonErrorSchema>;
56
+ declare const captchaErrorStatusSchema: z.ZodObject<{
57
+ type: z.ZodEnum<["aws", "cloudflare", "customcaptcha", "funcaptcha", "geetest", "hcaptcha", "lemincaptcha", "recaptcha", "textcaptcha"]>;
58
+ id: z.ZodString;
59
+ tabId: z.ZodNumber;
60
+ retryCount: z.ZodOptional<z.ZodNumber>;
61
+ status: z.ZodLiteral<"error">;
62
+ error: z.ZodObject<{
63
+ code: z.ZodEnum<["HIT_LIMIT", "MAX_RETRIES", "UNEXPECTED_SERVER_RESPONSE", "UNEXPECTED_ERROR"]>;
64
+ error: z.ZodOptional<z.ZodUnknown>;
65
+ }, "strip", z.ZodTypeAny, {
66
+ code: "HIT_LIMIT" | "MAX_RETRIES" | "UNEXPECTED_SERVER_RESPONSE" | "UNEXPECTED_ERROR";
67
+ error?: unknown;
68
+ }, {
69
+ code: "HIT_LIMIT" | "MAX_RETRIES" | "UNEXPECTED_SERVER_RESPONSE" | "UNEXPECTED_ERROR";
70
+ error?: unknown;
71
+ }>;
72
+ }, "strip", z.ZodTypeAny, {
73
+ error: {
74
+ code: "HIT_LIMIT" | "MAX_RETRIES" | "UNEXPECTED_SERVER_RESPONSE" | "UNEXPECTED_ERROR";
75
+ error?: unknown;
76
+ };
77
+ type: "aws" | "cloudflare" | "customcaptcha" | "funcaptcha" | "geetest" | "hcaptcha" | "lemincaptcha" | "recaptcha" | "textcaptcha";
78
+ status: "error";
79
+ id: string;
80
+ tabId: number;
81
+ retryCount?: number | undefined;
82
+ }, {
83
+ error: {
84
+ code: "HIT_LIMIT" | "MAX_RETRIES" | "UNEXPECTED_SERVER_RESPONSE" | "UNEXPECTED_ERROR";
85
+ error?: unknown;
86
+ };
87
+ type: "aws" | "cloudflare" | "customcaptcha" | "funcaptcha" | "geetest" | "hcaptcha" | "lemincaptcha" | "recaptcha" | "textcaptcha";
88
+ status: "error";
89
+ id: string;
90
+ tabId: number;
91
+ retryCount?: number | undefined;
92
+ }>;
93
+ export type CaptchaErrorStatus = z.infer<typeof captchaErrorStatusSchema>;
94
+ export declare const captchaSchema: z.ZodDiscriminatedUnion<"status", [z.ZodObject<{
95
+ type: z.ZodEnum<["aws", "cloudflare", "customcaptcha", "funcaptcha", "geetest", "hcaptcha", "lemincaptcha", "recaptcha", "textcaptcha"]>;
96
+ id: z.ZodString;
97
+ tabId: z.ZodNumber;
98
+ retryCount: z.ZodOptional<z.ZodNumber>;
99
+ status: z.ZodLiteral<"attached">;
100
+ }, "strip", z.ZodTypeAny, {
101
+ type: "aws" | "cloudflare" | "customcaptcha" | "funcaptcha" | "geetest" | "hcaptcha" | "lemincaptcha" | "recaptcha" | "textcaptcha";
102
+ status: "attached";
103
+ id: string;
104
+ tabId: number;
105
+ retryCount?: number | undefined;
106
+ }, {
107
+ type: "aws" | "cloudflare" | "customcaptcha" | "funcaptcha" | "geetest" | "hcaptcha" | "lemincaptcha" | "recaptcha" | "textcaptcha";
108
+ status: "attached";
109
+ id: string;
110
+ tabId: number;
111
+ retryCount?: number | undefined;
112
+ }>, z.ZodObject<{
113
+ type: z.ZodEnum<["aws", "cloudflare", "customcaptcha", "funcaptcha", "geetest", "hcaptcha", "lemincaptcha", "recaptcha", "textcaptcha"]>;
114
+ id: z.ZodString;
115
+ tabId: z.ZodNumber;
116
+ retryCount: z.ZodOptional<z.ZodNumber>;
117
+ status: z.ZodLiteral<"solving">;
118
+ }, "strip", z.ZodTypeAny, {
119
+ type: "aws" | "cloudflare" | "customcaptcha" | "funcaptcha" | "geetest" | "hcaptcha" | "lemincaptcha" | "recaptcha" | "textcaptcha";
120
+ status: "solving";
121
+ id: string;
122
+ tabId: number;
123
+ retryCount?: number | undefined;
124
+ }, {
125
+ type: "aws" | "cloudflare" | "customcaptcha" | "funcaptcha" | "geetest" | "hcaptcha" | "lemincaptcha" | "recaptcha" | "textcaptcha";
126
+ status: "solving";
127
+ id: string;
128
+ tabId: number;
129
+ retryCount?: number | undefined;
130
+ }>, z.ZodObject<{
131
+ type: z.ZodEnum<["aws", "cloudflare", "customcaptcha", "funcaptcha", "geetest", "hcaptcha", "lemincaptcha", "recaptcha", "textcaptcha"]>;
132
+ id: z.ZodString;
133
+ tabId: z.ZodNumber;
134
+ retryCount: z.ZodOptional<z.ZodNumber>;
135
+ status: z.ZodLiteral<"solved">;
136
+ }, "strip", z.ZodTypeAny, {
137
+ type: "aws" | "cloudflare" | "customcaptcha" | "funcaptcha" | "geetest" | "hcaptcha" | "lemincaptcha" | "recaptcha" | "textcaptcha";
138
+ status: "solved";
139
+ id: string;
140
+ tabId: number;
141
+ retryCount?: number | undefined;
142
+ }, {
143
+ type: "aws" | "cloudflare" | "customcaptcha" | "funcaptcha" | "geetest" | "hcaptcha" | "lemincaptcha" | "recaptcha" | "textcaptcha";
144
+ status: "solved";
145
+ id: string;
146
+ tabId: number;
147
+ retryCount?: number | undefined;
148
+ }>, z.ZodObject<{
149
+ type: z.ZodEnum<["aws", "cloudflare", "customcaptcha", "funcaptcha", "geetest", "hcaptcha", "lemincaptcha", "recaptcha", "textcaptcha"]>;
150
+ id: z.ZodString;
151
+ tabId: z.ZodNumber;
152
+ retryCount: z.ZodOptional<z.ZodNumber>;
153
+ status: z.ZodLiteral<"detached">;
154
+ }, "strip", z.ZodTypeAny, {
155
+ type: "aws" | "cloudflare" | "customcaptcha" | "funcaptcha" | "geetest" | "hcaptcha" | "lemincaptcha" | "recaptcha" | "textcaptcha";
156
+ status: "detached";
157
+ id: string;
158
+ tabId: number;
159
+ retryCount?: number | undefined;
160
+ }, {
161
+ type: "aws" | "cloudflare" | "customcaptcha" | "funcaptcha" | "geetest" | "hcaptcha" | "lemincaptcha" | "recaptcha" | "textcaptcha";
162
+ status: "detached";
163
+ id: string;
164
+ tabId: number;
165
+ retryCount?: number | undefined;
166
+ }>, z.ZodObject<{
167
+ type: z.ZodEnum<["aws", "cloudflare", "customcaptcha", "funcaptcha", "geetest", "hcaptcha", "lemincaptcha", "recaptcha", "textcaptcha"]>;
168
+ id: z.ZodString;
169
+ tabId: z.ZodNumber;
170
+ retryCount: z.ZodOptional<z.ZodNumber>;
171
+ status: z.ZodLiteral<"error">;
172
+ error: z.ZodObject<{
173
+ code: z.ZodEnum<["HIT_LIMIT", "MAX_RETRIES", "UNEXPECTED_SERVER_RESPONSE", "UNEXPECTED_ERROR"]>;
174
+ error: z.ZodOptional<z.ZodUnknown>;
175
+ }, "strip", z.ZodTypeAny, {
176
+ code: "HIT_LIMIT" | "MAX_RETRIES" | "UNEXPECTED_SERVER_RESPONSE" | "UNEXPECTED_ERROR";
177
+ error?: unknown;
178
+ }, {
179
+ code: "HIT_LIMIT" | "MAX_RETRIES" | "UNEXPECTED_SERVER_RESPONSE" | "UNEXPECTED_ERROR";
180
+ error?: unknown;
181
+ }>;
182
+ }, "strip", z.ZodTypeAny, {
183
+ error: {
184
+ code: "HIT_LIMIT" | "MAX_RETRIES" | "UNEXPECTED_SERVER_RESPONSE" | "UNEXPECTED_ERROR";
185
+ error?: unknown;
186
+ };
187
+ type: "aws" | "cloudflare" | "customcaptcha" | "funcaptcha" | "geetest" | "hcaptcha" | "lemincaptcha" | "recaptcha" | "textcaptcha";
188
+ status: "error";
189
+ id: string;
190
+ tabId: number;
191
+ retryCount?: number | undefined;
192
+ }, {
193
+ error: {
194
+ code: "HIT_LIMIT" | "MAX_RETRIES" | "UNEXPECTED_SERVER_RESPONSE" | "UNEXPECTED_ERROR";
195
+ error?: unknown;
196
+ };
197
+ type: "aws" | "cloudflare" | "customcaptcha" | "funcaptcha" | "geetest" | "hcaptcha" | "lemincaptcha" | "recaptcha" | "textcaptcha";
198
+ status: "error";
199
+ id: string;
200
+ tabId: number;
201
+ retryCount?: number | undefined;
202
+ }>]>;
203
+ export type Captcha = z.infer<typeof captchaSchema>;
204
+ export type CaptchaCallback = (captcha: Captcha) => Promise<void> | void;
205
+ export declare class CaptchaSolveError extends Error {
206
+ error: CaptchaError;
207
+ constructor(message: string, error: CaptchaError);
208
+ }
209
+ export declare class TimeoutError extends Error {
210
+ constructor(message: string);
211
+ }
212
+ export {};