@intuned/runtime-dev 1.3.18-interface.8 → 1.3.19-new-cli.0

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.
Files changed (205) hide show
  1. package/.babelrc +27 -0
  2. package/.claude/settings.local.json +7 -0
  3. package/.eslintignore +10 -0
  4. package/.eslintrc.js +39 -0
  5. package/CHANGELOG.md +1 -1
  6. package/InterfaceTemplate/__utils.ts +63 -0
  7. package/InterfaceTemplate/index.playwright.ts +6 -0
  8. package/bin/intuned +20 -2
  9. package/dist/commands/api/run.d.ts +6 -0
  10. package/dist/commands/api/run.js +119 -0
  11. package/dist/commands/auth-sessions/load.d.ts +2 -0
  12. package/dist/commands/auth-sessions/load.js +35 -0
  13. package/dist/commands/auth-sessions/run-check.d.ts +2 -0
  14. package/dist/commands/auth-sessions/run-check.js +74 -0
  15. package/dist/commands/auth-sessions/run-create.d.ts +2 -0
  16. package/dist/commands/auth-sessions/run-create.js +78 -0
  17. package/dist/commands/browser/save-state.d.ts +2 -0
  18. package/dist/commands/browser/save-state.js +17 -0
  19. package/dist/commands/browser/start-browser.d.ts +2 -0
  20. package/dist/commands/browser/start-browser.js +14 -0
  21. package/dist/commands/build.d.ts +1 -0
  22. package/dist/commands/build.js +83 -0
  23. package/dist/commands/common/browserUtils.d.ts +14 -0
  24. package/dist/commands/common/browserUtils.js +57 -0
  25. package/dist/commands/common/getFirstLineNumber.d.ts +9 -0
  26. package/dist/commands/common/getFirstLineNumber.js +101 -0
  27. package/dist/commands/common/getFirstLineNumber.test.js +227 -0
  28. package/dist/commands/common/projectExclusions.d.ts +2 -0
  29. package/dist/commands/common/projectExclusions.js +8 -0
  30. package/dist/commands/common/sendMessageToClient.d.ts +1 -0
  31. package/dist/commands/common/sendMessageToClient.js +10 -0
  32. package/dist/commands/common/tsNodeImport.d.ts +2 -0
  33. package/dist/commands/common/tsNodeImport.js +42 -0
  34. package/dist/commands/common/utils/fileUtils.d.ts +6 -0
  35. package/dist/commands/common/utils/fileUtils.js +32 -0
  36. package/dist/commands/common/utils/interfaceClient.d.ts +31 -0
  37. package/dist/commands/common/utils/interfaceClient.js +98 -0
  38. package/dist/commands/common/utils/settings.d.ts +2 -0
  39. package/dist/commands/common/utils/settings.js +31 -0
  40. package/dist/commands/common/utils/template.d.ts +2 -0
  41. package/dist/commands/common/utils/template.js +30 -0
  42. package/dist/commands/get-headless-user-agent.d.ts +1 -0
  43. package/dist/commands/get-headless-user-agent.js +18 -0
  44. package/dist/commands/interface/run.d.ts +1 -3
  45. package/dist/commands/interface/run.js +139 -2047
  46. package/dist/commands/ts-check.d.ts +2 -0
  47. package/dist/commands/ts-check.js +55 -0
  48. package/dist/common/Logger/Logger/index.d.ts +12 -0
  49. package/dist/common/Logger/Logger/index.js +60 -0
  50. package/dist/common/Logger/Logger/types.d.ts +8 -0
  51. package/dist/common/Logger/Logger/types.js +5 -0
  52. package/dist/common/Logger/index.d.ts +12 -0
  53. package/dist/common/Logger/index.js +60 -0
  54. package/dist/common/Logger/types.d.ts +8 -0
  55. package/dist/common/Logger/types.js +5 -0
  56. package/dist/common/asyncLocalStorage/index.d.ts +8 -9
  57. package/dist/common/asyncLocalStorage/index.js +9 -34
  58. package/dist/common/backendFunctions/getAuthSessionParameters.d.ts +1 -0
  59. package/dist/common/backendFunctions/getAuthSessionParameters.js +38 -0
  60. package/dist/common/binStartupScript.d.ts +1 -2
  61. package/dist/common/binStartupScript.js +25 -132
  62. package/dist/common/browserTabs.d.ts +72 -0
  63. package/dist/common/browserTabs.js +74 -0
  64. package/dist/common/cleanEnvironmentVariables.d.ts +1 -3
  65. package/dist/common/cleanEnvironmentVariables.js +7 -30
  66. package/dist/common/constants.d.ts +11 -13
  67. package/dist/common/constants.js +15 -58
  68. package/dist/common/contextStorageStateHelpers.d.ts +6 -8
  69. package/dist/common/contextStorageStateHelpers.js +26 -48
  70. package/dist/common/extension/extensionsHelpers.d.ts +11 -0
  71. package/dist/common/extension/extensionsHelpers.js +147 -0
  72. package/dist/common/extension/intunedExtensionServer.d.ts +24 -0
  73. package/dist/common/extension/intunedExtensionServer.js +178 -0
  74. package/dist/common/extension/types.d.ts +219 -0
  75. package/dist/common/extension/types.js +51 -0
  76. package/dist/common/formatZodError.d.ts +2 -0
  77. package/dist/{chunk-NDMVGENG.mjs → common/formatZodError.js} +9 -9
  78. package/dist/common/intunedJson.d.ts +244 -0
  79. package/dist/common/intunedJson.js +154 -0
  80. package/dist/common/jwtTokenManager.d.ts +4 -6
  81. package/dist/common/jwtTokenManager.js +40 -108
  82. package/dist/common/launchBrowser.d.ts +36 -0
  83. package/dist/common/launchBrowser.js +269 -0
  84. package/dist/common/playwrightContext.d.ts +29 -0
  85. package/dist/common/playwrightContext.js +148 -0
  86. package/dist/common/runApi/importUsingImportFunction.d.ts +7 -0
  87. package/dist/common/runApi/importUsingImportFunction.js +46 -0
  88. package/dist/common/runApi/index.d.ts +6 -9
  89. package/dist/common/runApi/index.js +73 -1782
  90. package/dist/common/settingsSchema.d.ts +6 -9
  91. package/dist/common/settingsSchema.js +18 -54
  92. package/dist/common/setupContextHook.d.ts +16 -0
  93. package/dist/common/setupContextHook.js +22 -0
  94. package/dist/common/telemetry.d.ts +3 -6
  95. package/dist/common/telemetry.js +8 -41
  96. package/dist/index.d.ts +4 -6
  97. package/dist/index.js +92 -784
  98. package/dist/runtime/RunError.d.ts +5 -0
  99. package/dist/runtime/RunError.js +19 -0
  100. package/dist/runtime/attemptStore.d.ts +2 -0
  101. package/dist/runtime/attemptStore.js +23 -0
  102. package/dist/runtime/captcha.d.ts +15 -0
  103. package/dist/runtime/captcha.js +191 -0
  104. package/dist/runtime/captcha.test.js +821 -0
  105. package/dist/runtime/downloadDirectory.d.ts +1 -0
  106. package/dist/runtime/downloadDirectory.js +19 -0
  107. package/dist/runtime/enums.d.js +5 -0
  108. package/dist/runtime/enums.d.ts +11 -0
  109. package/dist/runtime/enums.js +18 -0
  110. package/dist/runtime/executionHelpers.test.js +52 -0
  111. package/dist/runtime/export.d.js +5 -0
  112. package/dist/runtime/export.d.ts +284 -0
  113. package/dist/runtime/extendPayload.d.ts +2 -0
  114. package/dist/runtime/extendPayload.js +21 -0
  115. package/dist/runtime/extendTimeout.d.ts +1 -0
  116. package/dist/runtime/extendTimeout.js +23 -0
  117. package/dist/runtime/getAiGatewayConfig.d.ts +10 -0
  118. package/dist/runtime/getAiGatewayConfig.js +16 -0
  119. package/dist/runtime/getAuthSessionParameters.d.ts +1 -0
  120. package/dist/runtime/getAuthSessionParameters.js +20 -0
  121. package/dist/runtime/index.d.ts +10 -168
  122. package/dist/runtime/index.js +88 -779
  123. package/dist/runtime/persistentStore.d.ts +2 -0
  124. package/dist/runtime/persistentStore.js +37 -0
  125. package/dist/runtime/persistentStore.test.js +101 -0
  126. package/dist/runtime/runInfo.d.ts +2 -0
  127. package/dist/runtime/runInfo.js +21 -0
  128. package/dist/vendor/runtime-interface.d.ts +1 -0
  129. package/dist/vendor/runtime-interface.js +479 -0
  130. package/package.json +20 -74
  131. package/template.tsconfig.json +11 -0
  132. package/tsconfig.eslint.json +5 -0
  133. package/tsconfig.json +25 -0
  134. package/tsup.config.ts +12 -0
  135. package/typedoc.json +49 -0
  136. package/dist/chunk-6ZRJOUQS.mjs +0 -16
  137. package/dist/chunk-6ZRJOUQS.mjs.map +0 -1
  138. package/dist/chunk-7YL2JUTE.mjs +0 -146
  139. package/dist/chunk-7YL2JUTE.mjs.map +0 -1
  140. package/dist/chunk-B3T6RXPC.mjs +0 -794
  141. package/dist/chunk-B3T6RXPC.mjs.map +0 -1
  142. package/dist/chunk-FGV5T6SI.mjs +0 -27
  143. package/dist/chunk-FGV5T6SI.mjs.map +0 -1
  144. package/dist/chunk-G4PO5RIV.mjs +0 -85
  145. package/dist/chunk-G4PO5RIV.mjs.map +0 -1
  146. package/dist/chunk-LZOMFHX3.mjs +0 -38
  147. package/dist/chunk-LZOMFHX3.mjs.map +0 -1
  148. package/dist/chunk-NDMVGENG.mjs.map +0 -1
  149. package/dist/chunk-W4UX6G4X.mjs +0 -17
  150. package/dist/chunk-W4UX6G4X.mjs.map +0 -1
  151. package/dist/chunk-XC75QGFG.mjs +0 -1106
  152. package/dist/chunk-XC75QGFG.mjs.map +0 -1
  153. package/dist/chunk-XOAZ2MGA.mjs +0 -59
  154. package/dist/chunk-XOAZ2MGA.mjs.map +0 -1
  155. package/dist/commands/interface/run.d.mts +0 -3
  156. package/dist/commands/interface/run.js.map +0 -1
  157. package/dist/commands/interface/run.mjs +0 -255
  158. package/dist/commands/interface/run.mjs.map +0 -1
  159. package/dist/common/asyncLocalStorage/index.d.mts +0 -17
  160. package/dist/common/asyncLocalStorage/index.js.map +0 -1
  161. package/dist/common/asyncLocalStorage/index.mjs +0 -12
  162. package/dist/common/asyncLocalStorage/index.mjs.map +0 -1
  163. package/dist/common/binStartupScript.d.mts +0 -2
  164. package/dist/common/binStartupScript.js.map +0 -1
  165. package/dist/common/binStartupScript.mjs +0 -135
  166. package/dist/common/binStartupScript.mjs.map +0 -1
  167. package/dist/common/cleanEnvironmentVariables.d.mts +0 -3
  168. package/dist/common/cleanEnvironmentVariables.js.map +0 -1
  169. package/dist/common/cleanEnvironmentVariables.mjs +0 -8
  170. package/dist/common/cleanEnvironmentVariables.mjs.map +0 -1
  171. package/dist/common/constants.d.mts +0 -13
  172. package/dist/common/constants.js.map +0 -1
  173. package/dist/common/constants.mjs +0 -28
  174. package/dist/common/constants.mjs.map +0 -1
  175. package/dist/common/contextStorageStateHelpers.d.mts +0 -24
  176. package/dist/common/contextStorageStateHelpers.js.map +0 -1
  177. package/dist/common/contextStorageStateHelpers.mjs +0 -10
  178. package/dist/common/contextStorageStateHelpers.mjs.map +0 -1
  179. package/dist/common/jwtTokenManager.d.mts +0 -19
  180. package/dist/common/jwtTokenManager.js.map +0 -1
  181. package/dist/common/jwtTokenManager.mjs +0 -11
  182. package/dist/common/jwtTokenManager.mjs.map +0 -1
  183. package/dist/common/runApi/index.d.mts +0 -11
  184. package/dist/common/runApi/index.js.map +0 -1
  185. package/dist/common/runApi/index.mjs +0 -18
  186. package/dist/common/runApi/index.mjs.map +0 -1
  187. package/dist/common/settingsSchema.d.mts +0 -540
  188. package/dist/common/settingsSchema.js.map +0 -1
  189. package/dist/common/settingsSchema.mjs +0 -10
  190. package/dist/common/settingsSchema.mjs.map +0 -1
  191. package/dist/common/telemetry.d.mts +0 -6
  192. package/dist/common/telemetry.js.map +0 -1
  193. package/dist/common/telemetry.mjs +0 -31
  194. package/dist/common/telemetry.mjs.map +0 -1
  195. package/dist/export.d-BAUMB-lG.d.mts +0 -140
  196. package/dist/export.d-BAUMB-lG.d.ts +0 -140
  197. package/dist/index.d.mts +0 -6
  198. package/dist/index.js.map +0 -1
  199. package/dist/index.mjs +0 -47
  200. package/dist/index.mjs.map +0 -1
  201. package/dist/runtime/index.d.mts +0 -168
  202. package/dist/runtime/index.js.map +0 -1
  203. package/dist/runtime/index.mjs +0 -42
  204. package/dist/runtime/index.mjs.map +0 -1
  205. /package/dist/common/assets/{assets/browser_scripts.js → browser_scripts.js} +0 -0
@@ -0,0 +1,178 @@
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
+ var _extensionsHelpers = require("./extensionsHelpers");
14
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
15
+ class TabCaptchaState {
16
+ constructor(tabId) {
17
+ this.tabId = tabId;
18
+ this.captchasById = new Map();
19
+ this.subscribers = new Array();
20
+ }
21
+ subscribe(handler) {
22
+ this.subscribers.push(handler);
23
+ }
24
+ unsubscribe(handler, status) {
25
+ const index = this.subscribers.findIndex(subscriber => subscriber.handler === handler && (subscriber.status === status || !status));
26
+ if (index !== -1) {
27
+ this.subscribers.splice(index, 1);
28
+ }
29
+ }
30
+ getCaptchas() {
31
+ return [...this.captchasById.values()];
32
+ }
33
+ async upsertCaptcha(captcha) {
34
+ this.captchasById.set(captcha.id, captcha);
35
+ for (const subscriber of this.subscribers) {
36
+ if (!subscriber.status || subscriber.status === captcha.status) {
37
+ await subscriber.handler(captcha);
38
+ }
39
+ }
40
+ }
41
+ }
42
+ class ExtensionServer {
43
+ app = null;
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
+ }
98
+ async stop() {
99
+ if (!this.app) return;
100
+ const toClose = this.app;
101
+ this.app = null;
102
+ await toClose.close();
103
+ }
104
+ async getCaptchas(page, status) {
105
+ const tabId = await getTabId(page);
106
+ const tab = this.tabs.get(tabId);
107
+ if (!tab) return [];
108
+ const captchas = tab.getCaptchas();
109
+ if (!status) return captchas;
110
+ return captchas.filter(c => c.status === status && c.tabId === tabId);
111
+ }
112
+ async subscribe(page, handler, status) {
113
+ const tabId = await getTabId(page);
114
+ const tab = this.getOrCreateTab(tabId);
115
+ tab.subscribe({
116
+ handler,
117
+ status
118
+ });
119
+ }
120
+ async unsubscribe(page, handler, status) {
121
+ const tabId = await getTabId(page);
122
+ const tab = this.tabs.get(tabId);
123
+ if (!tab) return;
124
+ tab.unsubscribe(handler, status);
125
+ }
126
+ removeTab(tabId) {
127
+ this.tabs.delete(tabId);
128
+ }
129
+ async getTabId(page) {
130
+ return await getTabId(page);
131
+ }
132
+ }
133
+ exports.ExtensionServer = ExtensionServer;
134
+ let extensionServerSingleton = null;
135
+ function getIntunedExtensionServer() {
136
+ if (!extensionServerSingleton) {
137
+ throw new Error("Intuned Extension Server is not initialized.");
138
+ }
139
+ return extensionServerSingleton;
140
+ }
141
+ async function setupIntunedExtensionServer(captchaSolverSettings) {
142
+ if (!captchaSolverSettings) {
143
+ captchaSolverSettings = await (0, _extensionsHelpers.resolveCaptchaSolverSettings)();
144
+ }
145
+ if (!extensionServerSingleton) {
146
+ extensionServerSingleton = new ExtensionServer();
147
+ }
148
+ await extensionServerSingleton.start({
149
+ port: captchaSolverSettings.port ?? 9000
150
+ });
151
+ }
152
+ async function cleanIntunedExtensionServer() {
153
+ if (extensionServerSingleton) {
154
+ await extensionServerSingleton.stop();
155
+ extensionServerSingleton = null;
156
+ }
157
+ }
158
+ const TAB_ID_CACHE_KEY = "__INTUNED_CACHED_TAB_ID__";
159
+ async function getTabId(page) {
160
+ const cached = page[TAB_ID_CACHE_KEY];
161
+ if (cached !== undefined && typeof cached === "number") {
162
+ return cached;
163
+ }
164
+ let tabId;
165
+ try {
166
+ tabId = await page.evaluate("window.__INTUNED_TAB_ID__", {
167
+ timeout: 100
168
+ });
169
+ } catch {
170
+ await page.waitForFunction("window.__INTUNED_TAB_ID__ !== undefined", {
171
+ timeout: 15_000
172
+ });
173
+ tabId = await page.evaluate("window.__INTUNED_TAB_ID__");
174
+ }
175
+ const numericTabId = Number(tabId);
176
+ page[TAB_ID_CACHE_KEY] = numericTabId;
177
+ return numericTabId;
178
+ }
@@ -0,0 +1,219 @@
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
+ id: z.ZodString;
38
+ tabId: z.ZodNumber;
39
+ type: z.ZodEnum<["aws", "cloudflare", "customcaptcha", "funcaptcha", "geetest", "hcaptcha", "lemincaptcha", "recaptcha", "textcaptcha"]>;
40
+ retryCount: z.ZodOptional<z.ZodNumber>;
41
+ } & {
42
+ status: z.ZodEnum<["attached", "solving", "solved", "detached"]>;
43
+ }, "strip", z.ZodTypeAny, {
44
+ type: "aws" | "cloudflare" | "customcaptcha" | "funcaptcha" | "geetest" | "hcaptcha" | "lemincaptcha" | "recaptcha" | "textcaptcha";
45
+ status: "attached" | "solving" | "solved" | "detached";
46
+ id: string;
47
+ tabId: number;
48
+ retryCount?: number | undefined;
49
+ }, {
50
+ type: "aws" | "cloudflare" | "customcaptcha" | "funcaptcha" | "geetest" | "hcaptcha" | "lemincaptcha" | "recaptcha" | "textcaptcha";
51
+ status: "attached" | "solving" | "solved" | "detached";
52
+ id: string;
53
+ tabId: number;
54
+ retryCount?: number | undefined;
55
+ }>;
56
+ export type CaptchaNonError = z.infer<typeof captchaNonErrorSchema>;
57
+ declare const captchaErrorStatusSchema: z.ZodObject<{
58
+ id: z.ZodString;
59
+ tabId: z.ZodNumber;
60
+ type: z.ZodEnum<["aws", "cloudflare", "customcaptcha", "funcaptcha", "geetest", "hcaptcha", "lemincaptcha", "recaptcha", "textcaptcha"]>;
61
+ retryCount: z.ZodOptional<z.ZodNumber>;
62
+ } & {
63
+ status: z.ZodLiteral<"error">;
64
+ error: z.ZodObject<{
65
+ code: z.ZodEnum<["HIT_LIMIT", "MAX_RETRIES", "UNEXPECTED_SERVER_RESPONSE", "UNEXPECTED_ERROR"]>;
66
+ error: z.ZodOptional<z.ZodUnknown>;
67
+ }, "strip", z.ZodTypeAny, {
68
+ code: "HIT_LIMIT" | "MAX_RETRIES" | "UNEXPECTED_SERVER_RESPONSE" | "UNEXPECTED_ERROR";
69
+ error?: unknown;
70
+ }, {
71
+ code: "HIT_LIMIT" | "MAX_RETRIES" | "UNEXPECTED_SERVER_RESPONSE" | "UNEXPECTED_ERROR";
72
+ error?: unknown;
73
+ }>;
74
+ }, "strip", z.ZodTypeAny, {
75
+ error: {
76
+ code: "HIT_LIMIT" | "MAX_RETRIES" | "UNEXPECTED_SERVER_RESPONSE" | "UNEXPECTED_ERROR";
77
+ error?: unknown;
78
+ };
79
+ type: "aws" | "cloudflare" | "customcaptcha" | "funcaptcha" | "geetest" | "hcaptcha" | "lemincaptcha" | "recaptcha" | "textcaptcha";
80
+ status: "error";
81
+ id: string;
82
+ tabId: number;
83
+ retryCount?: number | undefined;
84
+ }, {
85
+ error: {
86
+ code: "HIT_LIMIT" | "MAX_RETRIES" | "UNEXPECTED_SERVER_RESPONSE" | "UNEXPECTED_ERROR";
87
+ error?: unknown;
88
+ };
89
+ type: "aws" | "cloudflare" | "customcaptcha" | "funcaptcha" | "geetest" | "hcaptcha" | "lemincaptcha" | "recaptcha" | "textcaptcha";
90
+ status: "error";
91
+ id: string;
92
+ tabId: number;
93
+ retryCount?: number | undefined;
94
+ }>;
95
+ export type CaptchaErrorStatus = z.infer<typeof captchaErrorStatusSchema>;
96
+ export declare const captchaSchema: z.ZodDiscriminatedUnion<"status", [z.ZodObject<{
97
+ id: z.ZodString;
98
+ tabId: z.ZodNumber;
99
+ type: z.ZodEnum<["aws", "cloudflare", "customcaptcha", "funcaptcha", "geetest", "hcaptcha", "lemincaptcha", "recaptcha", "textcaptcha"]>;
100
+ retryCount: z.ZodOptional<z.ZodNumber>;
101
+ } & {
102
+ status: z.ZodLiteral<"attached">;
103
+ }, "strip", z.ZodTypeAny, {
104
+ type: "aws" | "cloudflare" | "customcaptcha" | "funcaptcha" | "geetest" | "hcaptcha" | "lemincaptcha" | "recaptcha" | "textcaptcha";
105
+ status: "attached";
106
+ id: string;
107
+ tabId: number;
108
+ retryCount?: number | undefined;
109
+ }, {
110
+ type: "aws" | "cloudflare" | "customcaptcha" | "funcaptcha" | "geetest" | "hcaptcha" | "lemincaptcha" | "recaptcha" | "textcaptcha";
111
+ status: "attached";
112
+ id: string;
113
+ tabId: number;
114
+ retryCount?: number | undefined;
115
+ }>, z.ZodObject<{
116
+ id: z.ZodString;
117
+ tabId: z.ZodNumber;
118
+ type: z.ZodEnum<["aws", "cloudflare", "customcaptcha", "funcaptcha", "geetest", "hcaptcha", "lemincaptcha", "recaptcha", "textcaptcha"]>;
119
+ retryCount: z.ZodOptional<z.ZodNumber>;
120
+ } & {
121
+ status: z.ZodLiteral<"solving">;
122
+ }, "strip", z.ZodTypeAny, {
123
+ type: "aws" | "cloudflare" | "customcaptcha" | "funcaptcha" | "geetest" | "hcaptcha" | "lemincaptcha" | "recaptcha" | "textcaptcha";
124
+ status: "solving";
125
+ id: string;
126
+ tabId: number;
127
+ retryCount?: number | undefined;
128
+ }, {
129
+ type: "aws" | "cloudflare" | "customcaptcha" | "funcaptcha" | "geetest" | "hcaptcha" | "lemincaptcha" | "recaptcha" | "textcaptcha";
130
+ status: "solving";
131
+ id: string;
132
+ tabId: number;
133
+ retryCount?: number | undefined;
134
+ }>, z.ZodObject<{
135
+ id: z.ZodString;
136
+ tabId: z.ZodNumber;
137
+ type: z.ZodEnum<["aws", "cloudflare", "customcaptcha", "funcaptcha", "geetest", "hcaptcha", "lemincaptcha", "recaptcha", "textcaptcha"]>;
138
+ retryCount: z.ZodOptional<z.ZodNumber>;
139
+ } & {
140
+ status: z.ZodLiteral<"solved">;
141
+ }, "strip", z.ZodTypeAny, {
142
+ type: "aws" | "cloudflare" | "customcaptcha" | "funcaptcha" | "geetest" | "hcaptcha" | "lemincaptcha" | "recaptcha" | "textcaptcha";
143
+ status: "solved";
144
+ id: string;
145
+ tabId: number;
146
+ retryCount?: number | undefined;
147
+ }, {
148
+ type: "aws" | "cloudflare" | "customcaptcha" | "funcaptcha" | "geetest" | "hcaptcha" | "lemincaptcha" | "recaptcha" | "textcaptcha";
149
+ status: "solved";
150
+ id: string;
151
+ tabId: number;
152
+ retryCount?: number | undefined;
153
+ }>, z.ZodObject<{
154
+ id: z.ZodString;
155
+ tabId: z.ZodNumber;
156
+ type: z.ZodEnum<["aws", "cloudflare", "customcaptcha", "funcaptcha", "geetest", "hcaptcha", "lemincaptcha", "recaptcha", "textcaptcha"]>;
157
+ retryCount: z.ZodOptional<z.ZodNumber>;
158
+ } & {
159
+ status: z.ZodLiteral<"detached">;
160
+ }, "strip", z.ZodTypeAny, {
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
+ }, {
167
+ type: "aws" | "cloudflare" | "customcaptcha" | "funcaptcha" | "geetest" | "hcaptcha" | "lemincaptcha" | "recaptcha" | "textcaptcha";
168
+ status: "detached";
169
+ id: string;
170
+ tabId: number;
171
+ retryCount?: number | undefined;
172
+ }>, z.ZodObject<{
173
+ id: z.ZodString;
174
+ tabId: z.ZodNumber;
175
+ type: z.ZodEnum<["aws", "cloudflare", "customcaptcha", "funcaptcha", "geetest", "hcaptcha", "lemincaptcha", "recaptcha", "textcaptcha"]>;
176
+ retryCount: z.ZodOptional<z.ZodNumber>;
177
+ } & {
178
+ status: z.ZodLiteral<"error">;
179
+ error: z.ZodObject<{
180
+ code: z.ZodEnum<["HIT_LIMIT", "MAX_RETRIES", "UNEXPECTED_SERVER_RESPONSE", "UNEXPECTED_ERROR"]>;
181
+ error: z.ZodOptional<z.ZodUnknown>;
182
+ }, "strip", z.ZodTypeAny, {
183
+ code: "HIT_LIMIT" | "MAX_RETRIES" | "UNEXPECTED_SERVER_RESPONSE" | "UNEXPECTED_ERROR";
184
+ error?: unknown;
185
+ }, {
186
+ code: "HIT_LIMIT" | "MAX_RETRIES" | "UNEXPECTED_SERVER_RESPONSE" | "UNEXPECTED_ERROR";
187
+ error?: unknown;
188
+ }>;
189
+ }, "strip", z.ZodTypeAny, {
190
+ error: {
191
+ code: "HIT_LIMIT" | "MAX_RETRIES" | "UNEXPECTED_SERVER_RESPONSE" | "UNEXPECTED_ERROR";
192
+ error?: unknown;
193
+ };
194
+ type: "aws" | "cloudflare" | "customcaptcha" | "funcaptcha" | "geetest" | "hcaptcha" | "lemincaptcha" | "recaptcha" | "textcaptcha";
195
+ status: "error";
196
+ id: string;
197
+ tabId: number;
198
+ retryCount?: number | undefined;
199
+ }, {
200
+ error: {
201
+ code: "HIT_LIMIT" | "MAX_RETRIES" | "UNEXPECTED_SERVER_RESPONSE" | "UNEXPECTED_ERROR";
202
+ error?: unknown;
203
+ };
204
+ type: "aws" | "cloudflare" | "customcaptcha" | "funcaptcha" | "geetest" | "hcaptcha" | "lemincaptcha" | "recaptcha" | "textcaptcha";
205
+ status: "error";
206
+ id: string;
207
+ tabId: number;
208
+ retryCount?: number | undefined;
209
+ }>]>;
210
+ export type Captcha = z.infer<typeof captchaSchema>;
211
+ export type CaptchaCallback = (captcha: Captcha) => Promise<void> | void;
212
+ export declare class CaptchaSolveError extends Error {
213
+ error: CaptchaError;
214
+ constructor(message: string, error: CaptchaError);
215
+ }
216
+ export declare class TimeoutError extends Error {
217
+ constructor(message: string);
218
+ }
219
+ export {};
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.captchaTypeSchema = exports.captchaStatusSchema = exports.captchaSchema = exports.captchaErrorSchema = exports.captchaErrorCodeSchema = exports.TimeoutError = exports.CaptchaSolveError = void 0;
7
+ var _zod = require("zod");
8
+ const captchaTypeSchema = exports.captchaTypeSchema = _zod.z.enum(["aws", "cloudflare", "customcaptcha", "funcaptcha", "geetest", "hcaptcha", "lemincaptcha", "recaptcha", "textcaptcha"]);
9
+ const captchaStatusSchema = exports.captchaStatusSchema = _zod.z.enum(["attached", "solving", "solved", "error", "detached"]);
10
+ const captchaErrorCodeSchema = exports.captchaErrorCodeSchema = _zod.z.enum(["HIT_LIMIT", "MAX_RETRIES", "UNEXPECTED_SERVER_RESPONSE", "UNEXPECTED_ERROR"]);
11
+ const captchaErrorSchema = exports.captchaErrorSchema = _zod.z.object({
12
+ code: captchaErrorCodeSchema,
13
+ error: _zod.z.unknown().optional()
14
+ });
15
+ const captchaBaseSchema = _zod.z.object({
16
+ id: _zod.z.string().min(1),
17
+ tabId: _zod.z.number().int().positive(),
18
+ type: captchaTypeSchema,
19
+ retryCount: _zod.z.number().int().nonnegative().optional()
20
+ });
21
+ const captchaNonErrorSchema = captchaBaseSchema.extend({
22
+ status: captchaStatusSchema.exclude(["error"])
23
+ });
24
+ const captchaErrorStatusSchema = captchaBaseSchema.extend({
25
+ status: _zod.z.literal("error"),
26
+ error: captchaErrorSchema
27
+ });
28
+ const captchaSchema = exports.captchaSchema = _zod.z.discriminatedUnion("status", [captchaBaseSchema.extend({
29
+ status: _zod.z.literal("attached")
30
+ }), captchaBaseSchema.extend({
31
+ status: _zod.z.literal("solving")
32
+ }), captchaBaseSchema.extend({
33
+ status: _zod.z.literal("solved")
34
+ }), captchaBaseSchema.extend({
35
+ status: _zod.z.literal("detached")
36
+ }), captchaErrorStatusSchema]);
37
+ class CaptchaSolveError extends Error {
38
+ constructor(message, error) {
39
+ super(message);
40
+ this.error = error;
41
+ this.name = "CaptchaSolveError";
42
+ }
43
+ }
44
+ exports.CaptchaSolveError = CaptchaSolveError;
45
+ class TimeoutError extends Error {
46
+ constructor(message) {
47
+ super(message);
48
+ this.name = "TimeoutError";
49
+ }
50
+ }
51
+ exports.TimeoutError = TimeoutError;
@@ -0,0 +1,2 @@
1
+ import { ZodError } from "zod/v3";
2
+ export declare function formatZodError(zodError: ZodError): string[];
@@ -1,7 +1,12 @@
1
- // src/common/formatZodError.ts
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.formatZodError = formatZodError;
2
7
  function formatZodError(zodError) {
3
- const formattedErrors = zodError.errors.map((error) => {
4
- const path = error.path.map((segment) => {
8
+ const formattedErrors = zodError.errors.map(error => {
9
+ const path = error.path.map(segment => {
5
10
  return typeof segment === "number" ? `[${segment}]` : segment;
6
11
  }).join(".");
7
12
  if (path) {
@@ -10,9 +15,4 @@ function formatZodError(zodError) {
10
15
  return error.message;
11
16
  });
12
17
  return formattedErrors;
13
- }
14
-
15
- export {
16
- formatZodError
17
- };
18
- //# sourceMappingURL=chunk-NDMVGENG.mjs.map
18
+ }