@intuned/runtime-dev 1.3.18-interface.2 → 1.3.18-interface.21
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.
- package/.babelrc +6 -0
- package/.claude/settings.local.json +7 -0
- package/InterfaceTemplate/__utils.ts +3 -1
- package/dist/commands/api/run.d.ts +6 -0
- package/dist/commands/api/run.js +119 -0
- package/dist/commands/auth-sessions/load.d.ts +2 -0
- package/dist/commands/auth-sessions/load.js +35 -0
- package/dist/commands/auth-sessions/run-check.d.ts +2 -0
- package/dist/commands/auth-sessions/run-check.js +74 -0
- package/dist/commands/auth-sessions/run-create.d.ts +2 -0
- package/dist/commands/auth-sessions/run-create.js +78 -0
- package/dist/commands/browser/save-state.d.ts +2 -0
- package/dist/commands/browser/save-state.js +17 -0
- package/dist/commands/browser/start-browser.d.ts +2 -0
- package/dist/commands/browser/start-browser.js +14 -0
- package/dist/commands/build.d.ts +1 -0
- package/dist/commands/build.js +83 -0
- package/dist/commands/common/browserUtils.d.ts +14 -0
- package/dist/commands/common/browserUtils.js +57 -0
- package/dist/commands/common/getFirstLineNumber.d.ts +9 -0
- package/dist/commands/common/getFirstLineNumber.js +101 -0
- package/dist/commands/common/getFirstLineNumber.test.js +227 -0
- package/dist/commands/common/projectExclusions.d.ts +2 -0
- package/dist/commands/common/projectExclusions.js +8 -0
- package/dist/commands/common/sendMessageToClient.d.ts +1 -0
- package/dist/commands/common/sendMessageToClient.js +10 -0
- package/dist/commands/common/tsNodeImport.d.ts +2 -0
- package/dist/commands/common/tsNodeImport.js +42 -0
- package/dist/commands/common/utils/fileUtils.d.ts +6 -0
- package/dist/commands/common/utils/fileUtils.js +32 -0
- package/dist/commands/common/utils/interfaceClient.d.ts +31 -0
- package/dist/commands/common/utils/interfaceClient.js +98 -0
- package/dist/commands/common/utils/settings.d.ts +2 -0
- package/dist/commands/common/utils/settings.js +31 -0
- package/dist/commands/common/utils/template.d.ts +2 -0
- package/dist/commands/common/utils/template.js +30 -0
- package/dist/commands/get-headless-user-agent.d.ts +1 -0
- package/dist/commands/get-headless-user-agent.js +18 -0
- package/dist/commands/interface/run.d.ts +1 -0
- package/dist/commands/interface/run.js +189 -0
- package/dist/commands/intuned-cli/commands/attempt.command.d.ts +1 -0
- package/dist/commands/intuned-cli/commands/attempt.command.js +8 -0
- package/dist/commands/intuned-cli/commands/attempt_api.command.d.ts +1 -0
- package/dist/commands/intuned-cli/commands/attempt_api.command.js +30 -0
- package/dist/commands/intuned-cli/commands/attempt_authsession.command.d.ts +1 -0
- package/dist/commands/intuned-cli/commands/attempt_authsession.command.js +8 -0
- package/dist/commands/intuned-cli/commands/attempt_authsession_check.command.d.ts +1 -0
- package/dist/commands/intuned-cli/commands/attempt_authsession_check.command.js +19 -0
- package/dist/commands/intuned-cli/commands/attempt_authsession_create.command.d.ts +1 -0
- package/dist/commands/intuned-cli/commands/attempt_authsession_create.command.js +24 -0
- package/dist/commands/intuned-cli/commands/authsession.command.d.ts +1 -0
- package/dist/commands/intuned-cli/commands/authsession.command.js +8 -0
- package/dist/commands/intuned-cli/commands/authsession_record.command.d.ts +1 -0
- package/dist/commands/intuned-cli/commands/authsession_record.command.js +32 -0
- package/dist/commands/intuned-cli/commands/authsession_scaffold.command.d.ts +1 -0
- package/dist/commands/intuned-cli/commands/authsession_scaffold.command.js +16 -0
- package/dist/commands/intuned-cli/commands/build.command.d.ts +1 -0
- package/dist/commands/intuned-cli/commands/build.command.js +12 -0
- package/dist/commands/intuned-cli/commands/command.d.ts +2 -0
- package/dist/commands/intuned-cli/commands/command.js +9 -0
- package/dist/commands/intuned-cli/commands/deploy.command.d.ts +1 -0
- package/dist/commands/intuned-cli/commands/deploy.command.js +42 -0
- package/dist/commands/intuned-cli/commands/index.d.ts +18 -0
- package/dist/commands/intuned-cli/commands/index.js +203 -0
- package/dist/commands/intuned-cli/commands/provision.command.d.ts +13 -0
- package/dist/commands/intuned-cli/commands/provision.command.js +50 -0
- package/dist/commands/intuned-cli/commands/run.command.d.ts +1 -0
- package/dist/commands/intuned-cli/commands/run.command.js +8 -0
- package/dist/commands/intuned-cli/commands/run_api.command.d.ts +1 -0
- package/dist/commands/intuned-cli/commands/run_api.command.js +46 -0
- package/dist/commands/intuned-cli/commands/run_authsession.command.d.ts +35 -0
- package/dist/commands/intuned-cli/commands/run_authsession.command.js +17 -0
- package/dist/commands/intuned-cli/commands/run_authsession_create.command.d.ts +1 -0
- package/dist/commands/intuned-cli/commands/run_authsession_create.command.js +35 -0
- package/dist/commands/intuned-cli/commands/run_authsession_update.command.d.ts +1 -0
- package/dist/commands/intuned-cli/commands/run_authsession_update.command.js +35 -0
- package/dist/commands/intuned-cli/commands/run_authsession_validate.command.d.ts +1 -0
- package/dist/commands/intuned-cli/commands/run_authsession_validate.command.js +33 -0
- package/dist/commands/intuned-cli/commands/types.d.ts +39 -0
- package/dist/commands/intuned-cli/commands/types.js +33 -0
- package/dist/commands/intuned-cli/constants/index.d.ts +17 -0
- package/dist/commands/intuned-cli/constants/index.js +25 -0
- package/dist/commands/intuned-cli/controller/__test__/api.test.js +399 -0
- package/dist/commands/intuned-cli/controller/__test__/authSession.test.js +1061 -0
- package/dist/commands/intuned-cli/controller/api.d.ts +42 -0
- package/dist/commands/intuned-cli/controller/api.js +194 -0
- package/dist/commands/intuned-cli/controller/authSession.d.ts +209 -0
- package/dist/commands/intuned-cli/controller/authSession.js +425 -0
- package/dist/commands/intuned-cli/controller/build.d.ts +1 -0
- package/dist/commands/intuned-cli/controller/build.js +35 -0
- package/dist/commands/intuned-cli/controller/deploy.d.ts +5 -0
- package/dist/commands/intuned-cli/controller/deploy.js +317 -0
- package/dist/commands/intuned-cli/controller/index.d.ts +1 -0
- package/dist/commands/intuned-cli/controller/index.js +45 -0
- package/dist/commands/intuned-cli/controller/provision.d.ts +21 -0
- package/dist/commands/intuned-cli/controller/provision.js +299 -0
- package/dist/commands/intuned-cli/controller/scaffold.d.ts +1 -0
- package/dist/commands/intuned-cli/controller/scaffold.js +77 -0
- package/dist/commands/intuned-cli/helpers/__test__/browser.test.js +152 -0
- package/dist/commands/intuned-cli/helpers/__test__/tracing.test.js +41 -0
- package/dist/commands/intuned-cli/helpers/api.d.ts +3 -0
- package/dist/commands/intuned-cli/helpers/api.js +16 -0
- package/dist/commands/intuned-cli/helpers/auth.d.ts +46 -0
- package/dist/commands/intuned-cli/helpers/auth.js +147 -0
- package/dist/commands/intuned-cli/helpers/backend.d.ts +8 -0
- package/dist/commands/intuned-cli/helpers/backend.js +35 -0
- package/dist/commands/intuned-cli/helpers/browser.d.ts +14 -0
- package/dist/commands/intuned-cli/helpers/browser.js +93 -0
- package/dist/commands/intuned-cli/helpers/context.d.ts +3 -0
- package/dist/commands/intuned-cli/helpers/context.js +33 -0
- package/dist/commands/intuned-cli/helpers/errors.d.ts +16 -0
- package/dist/commands/intuned-cli/helpers/errors.js +44 -0
- package/dist/commands/intuned-cli/helpers/index.d.ts +12 -0
- package/dist/commands/intuned-cli/helpers/index.js +137 -0
- package/dist/commands/intuned-cli/helpers/intunedJson.d.ts +39 -0
- package/dist/commands/intuned-cli/helpers/intunedJson.js +20 -0
- package/dist/commands/intuned-cli/helpers/prompts.d.ts +3 -0
- package/dist/commands/intuned-cli/helpers/prompts.js +71 -0
- package/dist/commands/intuned-cli/helpers/proxy.d.ts +5 -0
- package/dist/commands/intuned-cli/helpers/proxy.js +23 -0
- package/dist/commands/intuned-cli/helpers/terminal.d.ts +5 -0
- package/dist/commands/intuned-cli/helpers/terminal.js +13 -0
- package/dist/commands/intuned-cli/helpers/timeout.d.ts +1 -0
- package/dist/commands/intuned-cli/helpers/timeout.js +23 -0
- package/dist/commands/intuned-cli/helpers/traces.d.ts +2 -0
- package/dist/commands/intuned-cli/helpers/traces.js +32 -0
- package/dist/commands/intuned-cli/helpers/validation.d.ts +2 -0
- package/dist/commands/intuned-cli/helpers/validation.js +14 -0
- package/dist/commands/intuned-cli/helpers/wrapper.d.ts +2 -0
- package/dist/commands/intuned-cli/helpers/wrapper.js +76 -0
- package/dist/commands/intuned-cli/index.d.ts +1 -0
- package/dist/commands/intuned-cli/index.js +16 -0
- package/dist/commands/intuned-cli/main.d.ts +1 -0
- package/dist/commands/intuned-cli/main.js +35 -0
- package/dist/commands/intuned-cli/types.d.ts +70 -0
- package/dist/commands/intuned-cli/types.js +22 -0
- package/dist/commands/ts-check.d.ts +2 -0
- package/dist/commands/ts-check.js +55 -0
- package/dist/common/Logger/Logger/index.d.ts +12 -0
- package/dist/common/Logger/Logger/index.js +60 -0
- package/dist/common/Logger/Logger/types.d.ts +8 -0
- package/dist/common/Logger/Logger/types.js +5 -0
- package/dist/common/Logger/index.d.ts +12 -0
- package/dist/common/Logger/index.js +60 -0
- package/dist/common/Logger/types.d.ts +8 -0
- package/dist/common/Logger/types.js +5 -0
- package/dist/common/assets/browser_scripts.js +2580 -0
- package/dist/common/asyncLocalStorage/index.d.ts +16 -0
- package/dist/common/asyncLocalStorage/index.js +17 -0
- package/dist/common/backendFunctions/getAuthSessionParameters.d.ts +1 -0
- package/dist/common/backendFunctions/getAuthSessionParameters.js +38 -0
- package/dist/common/binStartupScript.d.ts +1 -0
- package/dist/common/binStartupScript.js +36 -0
- package/dist/common/browserTabs.d.ts +72 -0
- package/dist/common/browserTabs.js +74 -0
- package/dist/common/cleanEnvironmentVariables.d.ts +1 -0
- package/dist/common/cleanEnvironmentVariables.js +16 -0
- package/dist/common/constants.d.ts +11 -0
- package/dist/common/constants.js +17 -0
- package/dist/common/contextStorageStateHelpers.d.ts +22 -0
- package/dist/common/contextStorageStateHelpers.js +84 -0
- package/dist/common/extension/extensionsHelpers.d.ts +11 -0
- package/dist/common/extension/extensionsHelpers.js +147 -0
- package/dist/common/extension/intunedExtensionServer.d.ts +24 -0
- package/dist/common/extension/intunedExtensionServer.js +178 -0
- package/dist/common/extension/types.d.ts +219 -0
- package/dist/common/extension/types.js +51 -0
- package/dist/common/formatZodError.d.ts +2 -0
- package/dist/common/formatZodError.js +18 -0
- package/dist/common/intunedJson.d.ts +229 -0
- package/dist/common/intunedJson.js +132 -0
- package/dist/common/jwtTokenManager.d.ts +17 -0
- package/dist/common/jwtTokenManager.js +113 -0
- package/dist/common/launchBrowser.d.ts +34 -0
- package/dist/common/launchBrowser.js +247 -0
- package/dist/common/playwrightContext.d.ts +29 -0
- package/dist/common/playwrightContext.js +148 -0
- package/dist/common/runApi/importUsingImportFunction.d.ts +7 -0
- package/dist/common/runApi/importUsingImportFunction.js +46 -0
- package/dist/common/runApi/index.d.ts +8 -0
- package/dist/common/runApi/index.js +177 -0
- package/dist/common/settingsSchema.d.ts +537 -0
- package/dist/common/settingsSchema.js +57 -0
- package/dist/common/setupContextHook.d.ts +16 -0
- package/dist/common/setupContextHook.js +22 -0
- package/dist/common/telemetry.d.ts +3 -0
- package/dist/common/telemetry.js +31 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +117 -0
- package/dist/runtime/RunError.d.ts +5 -0
- package/dist/runtime/RunError.js +19 -0
- package/dist/runtime/attemptStore.d.ts +2 -0
- package/dist/runtime/attemptStore.js +23 -0
- package/dist/runtime/captcha.d.ts +15 -0
- package/dist/runtime/captcha.js +191 -0
- package/dist/runtime/captcha.test.js +821 -0
- package/dist/runtime/downloadDirectory.d.ts +1 -0
- package/dist/runtime/downloadDirectory.js +19 -0
- package/dist/runtime/enums.d.js +5 -0
- package/dist/runtime/enums.d.ts +11 -0
- package/dist/runtime/enums.js +18 -0
- package/dist/runtime/executionHelpers.test.js +52 -0
- package/dist/runtime/export.d.js +5 -0
- package/dist/runtime/export.d.ts +284 -0
- package/dist/runtime/extendPayload.d.ts +2 -0
- package/dist/runtime/extendPayload.js +21 -0
- package/dist/runtime/extendTimeout.d.ts +1 -0
- package/dist/runtime/extendTimeout.js +23 -0
- package/dist/runtime/getAiGatewayConfig.d.ts +10 -0
- package/dist/runtime/getAiGatewayConfig.js +16 -0
- package/dist/runtime/getAuthSessionParameters.d.ts +1 -0
- package/dist/runtime/getAuthSessionParameters.js +20 -0
- package/dist/runtime/index.d.ts +10 -0
- package/dist/runtime/index.js +111 -0
- package/dist/runtime/persistentStore.d.ts +2 -0
- package/dist/runtime/persistentStore.js +37 -0
- package/dist/runtime/persistentStore.test.js +101 -0
- package/dist/runtime/runInfo.d.ts +2 -0
- package/dist/runtime/runInfo.js +21 -0
- package/dist/vendor/runtime-interface.d.ts +1 -0
- package/dist/vendor/runtime-interface.js +479 -0
- package/package.json +8 -3
- package/tsup.config.ts +12 -0
- package/WebTemplate.zip +0 -0
- 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,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,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
|
+
}
|