@intuned/runtime-dev 1.3.18-interface.2 → 1.3.18-interface.4

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 (223) hide show
  1. package/.turbo/turbo-build.log +2 -0
  2. package/dist/commands/api/run.d.ts +6 -0
  3. package/dist/commands/api/run.js +120 -0
  4. package/dist/commands/auth-sessions/load.d.ts +2 -0
  5. package/dist/commands/auth-sessions/load.js +35 -0
  6. package/dist/commands/auth-sessions/run-check.d.ts +2 -0
  7. package/dist/commands/auth-sessions/run-check.js +75 -0
  8. package/dist/commands/auth-sessions/run-create.d.ts +2 -0
  9. package/dist/commands/auth-sessions/run-create.js +79 -0
  10. package/dist/commands/browser/save-state.d.ts +2 -0
  11. package/dist/commands/browser/save-state.js +17 -0
  12. package/dist/commands/browser/start-browser.d.ts +2 -0
  13. package/dist/commands/browser/start-browser.js +14 -0
  14. package/dist/commands/build.d.ts +1 -0
  15. package/dist/commands/build.js +84 -0
  16. package/dist/commands/common/browserUtils.d.ts +14 -0
  17. package/dist/commands/common/browserUtils.js +58 -0
  18. package/dist/commands/common/getFirstLineNumber.d.ts +9 -0
  19. package/dist/commands/common/getFirstLineNumber.js +101 -0
  20. package/dist/commands/common/getFirstLineNumber.test.js +228 -0
  21. package/dist/commands/common/projectExclusions.d.ts +2 -0
  22. package/dist/commands/common/projectExclusions.js +8 -0
  23. package/dist/commands/common/sendMessageToClient.d.ts +1 -0
  24. package/dist/commands/common/sendMessageToClient.js +10 -0
  25. package/dist/commands/common/tsNodeImport.d.ts +2 -0
  26. package/dist/commands/common/tsNodeImport.js +43 -0
  27. package/dist/commands/common/utils/fileUtils.d.ts +6 -0
  28. package/dist/commands/common/utils/fileUtils.js +33 -0
  29. package/dist/commands/common/utils/interfaceClient.d.ts +31 -0
  30. package/dist/commands/common/utils/interfaceClient.js +99 -0
  31. package/dist/commands/common/utils/settings.d.ts +2 -0
  32. package/dist/commands/common/utils/settings.js +31 -0
  33. package/dist/commands/common/utils/template.d.ts +2 -0
  34. package/dist/commands/common/utils/template.js +31 -0
  35. package/dist/commands/get-headless-user-agent.d.ts +1 -0
  36. package/dist/commands/get-headless-user-agent.js +18 -0
  37. package/dist/commands/interface/pingPong.d.ts +2 -0
  38. package/dist/commands/interface/pingPong.js +11 -0
  39. package/dist/commands/interface/run.d.ts +1 -0
  40. package/dist/commands/interface/run.js +190 -0
  41. package/dist/commands/interface/runApi.d.ts +1 -0
  42. package/dist/commands/interface/runApi.js +102 -0
  43. package/dist/commands/intuned-cli/commands/attempt.command.d.ts +1 -0
  44. package/dist/commands/intuned-cli/commands/attempt.command.js +8 -0
  45. package/dist/commands/intuned-cli/commands/attempt_api.command.d.ts +1 -0
  46. package/dist/commands/intuned-cli/commands/attempt_api.command.js +30 -0
  47. package/dist/commands/intuned-cli/commands/attempt_authsession.command.d.ts +1 -0
  48. package/dist/commands/intuned-cli/commands/attempt_authsession.command.js +8 -0
  49. package/dist/commands/intuned-cli/commands/attempt_authsession_check.command.d.ts +1 -0
  50. package/dist/commands/intuned-cli/commands/attempt_authsession_check.command.js +19 -0
  51. package/dist/commands/intuned-cli/commands/attempt_authsession_create.command.d.ts +1 -0
  52. package/dist/commands/intuned-cli/commands/attempt_authsession_create.command.js +24 -0
  53. package/dist/commands/intuned-cli/commands/authsession.command.d.ts +1 -0
  54. package/dist/commands/intuned-cli/commands/authsession.command.js +8 -0
  55. package/dist/commands/intuned-cli/commands/authsession_record.command.d.ts +1 -0
  56. package/dist/commands/intuned-cli/commands/authsession_record.command.js +32 -0
  57. package/dist/commands/intuned-cli/commands/authsession_scaffold.command.d.ts +1 -0
  58. package/dist/commands/intuned-cli/commands/authsession_scaffold.command.js +16 -0
  59. package/dist/commands/intuned-cli/commands/build.command.d.ts +1 -0
  60. package/dist/commands/intuned-cli/commands/build.command.js +12 -0
  61. package/dist/commands/intuned-cli/commands/command.d.ts +2 -0
  62. package/dist/commands/intuned-cli/commands/command.js +9 -0
  63. package/dist/commands/intuned-cli/commands/deploy.command.d.ts +1 -0
  64. package/dist/commands/intuned-cli/commands/deploy.command.js +42 -0
  65. package/dist/commands/intuned-cli/commands/index.d.ts +18 -0
  66. package/dist/commands/intuned-cli/commands/index.js +203 -0
  67. package/dist/commands/intuned-cli/commands/provision.command.d.ts +13 -0
  68. package/dist/commands/intuned-cli/commands/provision.command.js +50 -0
  69. package/dist/commands/intuned-cli/commands/run.command.d.ts +1 -0
  70. package/dist/commands/intuned-cli/commands/run.command.js +8 -0
  71. package/dist/commands/intuned-cli/commands/run_api.command.d.ts +1 -0
  72. package/dist/commands/intuned-cli/commands/run_api.command.js +46 -0
  73. package/dist/commands/intuned-cli/commands/run_authsession.command.d.ts +34 -0
  74. package/dist/commands/intuned-cli/commands/run_authsession.command.js +17 -0
  75. package/dist/commands/intuned-cli/commands/run_authsession_create.command.d.ts +1 -0
  76. package/dist/commands/intuned-cli/commands/run_authsession_create.command.js +35 -0
  77. package/dist/commands/intuned-cli/commands/run_authsession_update.command.d.ts +1 -0
  78. package/dist/commands/intuned-cli/commands/run_authsession_update.command.js +35 -0
  79. package/dist/commands/intuned-cli/commands/run_authsession_validate.command.d.ts +1 -0
  80. package/dist/commands/intuned-cli/commands/run_authsession_validate.command.js +33 -0
  81. package/dist/commands/intuned-cli/commands/types.d.ts +39 -0
  82. package/dist/commands/intuned-cli/commands/types.js +33 -0
  83. package/dist/commands/intuned-cli/constants/index.d.ts +17 -0
  84. package/dist/commands/intuned-cli/constants/index.js +25 -0
  85. package/dist/commands/intuned-cli/controller/__test__/api.test.js +398 -0
  86. package/dist/commands/intuned-cli/controller/__test__/authSession.test.js +1060 -0
  87. package/dist/commands/intuned-cli/controller/api.d.ts +42 -0
  88. package/dist/commands/intuned-cli/controller/api.js +195 -0
  89. package/dist/commands/intuned-cli/controller/authSession.d.ts +209 -0
  90. package/dist/commands/intuned-cli/controller/authSession.js +425 -0
  91. package/dist/commands/intuned-cli/controller/build.d.ts +1 -0
  92. package/dist/commands/intuned-cli/controller/build.js +36 -0
  93. package/dist/commands/intuned-cli/controller/deploy.d.ts +5 -0
  94. package/dist/commands/intuned-cli/controller/deploy.js +318 -0
  95. package/dist/commands/intuned-cli/controller/index.d.ts +1 -0
  96. package/dist/commands/intuned-cli/controller/index.js +46 -0
  97. package/dist/commands/intuned-cli/controller/provision.d.ts +21 -0
  98. package/dist/commands/intuned-cli/controller/provision.js +300 -0
  99. package/dist/commands/intuned-cli/controller/scaffold.d.ts +1 -0
  100. package/dist/commands/intuned-cli/controller/scaffold.js +77 -0
  101. package/dist/commands/intuned-cli/helpers/__test__/browser.test.js +152 -0
  102. package/dist/commands/intuned-cli/helpers/__test__/tracing.test.js +41 -0
  103. package/dist/commands/intuned-cli/helpers/api.d.ts +3 -0
  104. package/dist/commands/intuned-cli/helpers/api.js +16 -0
  105. package/dist/commands/intuned-cli/helpers/auth.d.ts +46 -0
  106. package/dist/commands/intuned-cli/helpers/auth.js +147 -0
  107. package/dist/commands/intuned-cli/helpers/backend.d.ts +8 -0
  108. package/dist/commands/intuned-cli/helpers/backend.js +35 -0
  109. package/dist/commands/intuned-cli/helpers/browser.d.ts +14 -0
  110. package/dist/commands/intuned-cli/helpers/browser.js +93 -0
  111. package/dist/commands/intuned-cli/helpers/context.d.ts +3 -0
  112. package/dist/commands/intuned-cli/helpers/context.js +33 -0
  113. package/dist/commands/intuned-cli/helpers/errors.d.ts +16 -0
  114. package/dist/commands/intuned-cli/helpers/errors.js +44 -0
  115. package/dist/commands/intuned-cli/helpers/index.d.ts +12 -0
  116. package/dist/commands/intuned-cli/helpers/index.js +137 -0
  117. package/dist/commands/intuned-cli/helpers/intunedJson.d.ts +39 -0
  118. package/dist/commands/intuned-cli/helpers/intunedJson.js +20 -0
  119. package/dist/commands/intuned-cli/helpers/prompts.d.ts +3 -0
  120. package/dist/commands/intuned-cli/helpers/prompts.js +71 -0
  121. package/dist/commands/intuned-cli/helpers/proxy.d.ts +5 -0
  122. package/dist/commands/intuned-cli/helpers/proxy.js +23 -0
  123. package/dist/commands/intuned-cli/helpers/terminal.d.ts +5 -0
  124. package/dist/commands/intuned-cli/helpers/terminal.js +13 -0
  125. package/dist/commands/intuned-cli/helpers/timeout.d.ts +1 -0
  126. package/dist/commands/intuned-cli/helpers/timeout.js +23 -0
  127. package/dist/commands/intuned-cli/helpers/traces.d.ts +2 -0
  128. package/dist/commands/intuned-cli/helpers/traces.js +32 -0
  129. package/dist/commands/intuned-cli/helpers/validation.d.ts +2 -0
  130. package/dist/commands/intuned-cli/helpers/validation.js +14 -0
  131. package/dist/commands/intuned-cli/helpers/wrapper.d.ts +2 -0
  132. package/dist/commands/intuned-cli/helpers/wrapper.js +76 -0
  133. package/dist/commands/intuned-cli/index.d.ts +1 -0
  134. package/dist/commands/intuned-cli/index.js +16 -0
  135. package/dist/commands/intuned-cli/main.d.ts +1 -0
  136. package/dist/commands/intuned-cli/main.js +36 -0
  137. package/dist/commands/intuned-cli/types.d.ts +70 -0
  138. package/dist/commands/intuned-cli/types.js +22 -0
  139. package/dist/commands/ts-check.d.ts +2 -0
  140. package/dist/commands/ts-check.js +56 -0
  141. package/dist/common/Logger/Logger/index.d.ts +12 -0
  142. package/dist/common/Logger/Logger/index.js +60 -0
  143. package/dist/common/Logger/Logger/types.d.ts +8 -0
  144. package/dist/common/Logger/Logger/types.js +5 -0
  145. package/dist/common/Logger/index.d.ts +12 -0
  146. package/dist/common/Logger/index.js +60 -0
  147. package/dist/common/Logger/types.d.ts +8 -0
  148. package/dist/common/Logger/types.js +5 -0
  149. package/dist/common/assets/browser_scripts.js +2580 -0
  150. package/dist/common/asyncLocalStorage/index.d.ts +16 -0
  151. package/dist/common/asyncLocalStorage/index.js +17 -0
  152. package/dist/common/backendFunctions/getAuthSessionParameters.d.ts +1 -0
  153. package/dist/common/backendFunctions/getAuthSessionParameters.js +38 -0
  154. package/dist/common/binStartupScript.d.ts +1 -0
  155. package/dist/common/binStartupScript.js +37 -0
  156. package/dist/common/browserTabs.d.ts +72 -0
  157. package/dist/common/browserTabs.js +74 -0
  158. package/dist/common/cleanEnvironmentVariables.d.ts +1 -0
  159. package/dist/common/cleanEnvironmentVariables.js +16 -0
  160. package/dist/common/constants.d.ts +11 -0
  161. package/dist/common/constants.js +17 -0
  162. package/dist/common/contextStorageStateHelpers.d.ts +22 -0
  163. package/dist/common/contextStorageStateHelpers.js +84 -0
  164. package/dist/common/extension/extensionsHelpers.d.ts +11 -0
  165. package/dist/common/extension/extensionsHelpers.js +147 -0
  166. package/dist/common/extension/intunedExtensionServer.d.ts +24 -0
  167. package/dist/common/extension/intunedExtensionServer.js +178 -0
  168. package/dist/common/extension/types.d.ts +212 -0
  169. package/dist/common/extension/types.js +51 -0
  170. package/dist/common/formatZodError.d.ts +2 -0
  171. package/dist/common/formatZodError.js +18 -0
  172. package/dist/common/intunedJson.d.ts +229 -0
  173. package/dist/common/intunedJson.js +133 -0
  174. package/dist/common/jwtTokenManager.d.ts +17 -0
  175. package/dist/common/jwtTokenManager.js +114 -0
  176. package/dist/common/launchBrowser.d.ts +34 -0
  177. package/dist/common/launchBrowser.js +248 -0
  178. package/dist/common/playwrightContext.d.ts +30 -0
  179. package/dist/common/playwrightContext.js +153 -0
  180. package/dist/common/runApi/importUsingImportFunction.d.ts +7 -0
  181. package/dist/common/runApi/importUsingImportFunction.js +46 -0
  182. package/dist/common/runApi/index.d.ts +8 -0
  183. package/dist/common/runApi/index.js +186 -0
  184. package/dist/common/settingsSchema.d.ts +533 -0
  185. package/dist/common/settingsSchema.js +58 -0
  186. package/dist/common/setupContextHook.d.ts +16 -0
  187. package/dist/common/setupContextHook.js +22 -0
  188. package/dist/common/telemetry.d.ts +3 -0
  189. package/dist/common/telemetry.js +32 -0
  190. package/dist/index.d.ts +4 -0
  191. package/dist/index.js +117 -0
  192. package/dist/runtime/RunError.d.ts +5 -0
  193. package/dist/runtime/RunError.js +19 -0
  194. package/dist/runtime/attemptStore.d.ts +2 -0
  195. package/dist/runtime/attemptStore.js +23 -0
  196. package/dist/runtime/captcha.d.ts +15 -0
  197. package/dist/runtime/captcha.js +191 -0
  198. package/dist/runtime/captcha.test.js +821 -0
  199. package/dist/runtime/downloadDirectory.d.ts +1 -0
  200. package/dist/runtime/downloadDirectory.js +19 -0
  201. package/dist/runtime/enums.d.js +5 -0
  202. package/dist/runtime/enums.d.ts +11 -0
  203. package/dist/runtime/enums.js +18 -0
  204. package/dist/runtime/executionHelpers.test.js +52 -0
  205. package/dist/runtime/export.d.js +5 -0
  206. package/dist/runtime/export.d.ts +284 -0
  207. package/dist/runtime/extendPayload.d.ts +2 -0
  208. package/dist/runtime/extendPayload.js +21 -0
  209. package/dist/runtime/extendTimeout.d.ts +1 -0
  210. package/dist/runtime/extendTimeout.js +23 -0
  211. package/dist/runtime/getAiGatewayConfig.d.ts +10 -0
  212. package/dist/runtime/getAiGatewayConfig.js +16 -0
  213. package/dist/runtime/getAuthSessionParameters.d.ts +1 -0
  214. package/dist/runtime/getAuthSessionParameters.js +20 -0
  215. package/dist/runtime/index.d.ts +10 -0
  216. package/dist/runtime/index.js +111 -0
  217. package/dist/runtime/persistentStore.d.ts +2 -0
  218. package/dist/runtime/persistentStore.js +37 -0
  219. package/dist/runtime/persistentStore.test.js +101 -0
  220. package/dist/runtime/runInfo.d.ts +2 -0
  221. package/dist/runtime/runInfo.js +21 -0
  222. package/package.json +2 -4
  223. package/api/sample.ts +0 -4
@@ -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,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 {};
@@ -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[];
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.formatZodError = formatZodError;
7
+ function formatZodError(zodError) {
8
+ const formattedErrors = zodError.errors.map(error => {
9
+ const path = error.path.map(segment => {
10
+ return typeof segment === "number" ? `[${segment}]` : segment;
11
+ }).join(".");
12
+ if (path) {
13
+ return `${path} is invalid - ${error.message}`;
14
+ }
15
+ return error.message;
16
+ });
17
+ return formattedErrors;
18
+ }