@intuned/runtime 1.3.17 → 1.3.18-interface.7
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/bin/intuned +0 -0
- package/bin/intuned-interface +7 -0
- package/dist/chunk-6ZRJOUQS.mjs +16 -0
- package/dist/chunk-6ZRJOUQS.mjs.map +1 -0
- package/dist/chunk-7YL2JUTE.mjs +146 -0
- package/dist/chunk-7YL2JUTE.mjs.map +1 -0
- package/dist/chunk-B3T6RXPC.mjs +794 -0
- package/dist/chunk-B3T6RXPC.mjs.map +1 -0
- package/dist/chunk-FGV5T6SI.mjs +27 -0
- package/dist/chunk-FGV5T6SI.mjs.map +1 -0
- package/dist/chunk-G4PO5RIV.mjs +85 -0
- package/dist/chunk-G4PO5RIV.mjs.map +1 -0
- package/dist/chunk-LZOMFHX3.mjs +38 -0
- package/dist/chunk-LZOMFHX3.mjs.map +1 -0
- package/dist/{common/formatZodError.js → chunk-NDMVGENG.mjs} +9 -9
- package/dist/chunk-NDMVGENG.mjs.map +1 -0
- package/dist/chunk-W4UX6G4X.mjs +17 -0
- package/dist/chunk-W4UX6G4X.mjs.map +1 -0
- package/dist/chunk-XC75QGFG.mjs +1106 -0
- package/dist/chunk-XC75QGFG.mjs.map +1 -0
- package/dist/chunk-XOAZ2MGA.mjs +59 -0
- package/dist/chunk-XOAZ2MGA.mjs.map +1 -0
- package/dist/commands/interface/run.d.mts +3 -0
- package/dist/commands/interface/run.d.ts +3 -1
- package/dist/commands/interface/run.js +2060 -178
- package/dist/commands/interface/run.js.map +1 -0
- package/dist/commands/interface/run.mjs +255 -0
- package/dist/commands/interface/run.mjs.map +1 -0
- package/dist/common/asyncLocalStorage/index.d.mts +17 -0
- package/dist/common/asyncLocalStorage/index.d.ts +9 -8
- package/dist/common/asyncLocalStorage/index.js +34 -9
- package/dist/common/asyncLocalStorage/index.js.map +1 -0
- package/dist/common/asyncLocalStorage/index.mjs +12 -0
- package/dist/common/asyncLocalStorage/index.mjs.map +1 -0
- package/dist/common/binStartupScript.d.mts +2 -0
- package/dist/common/binStartupScript.d.ts +2 -1
- package/dist/common/binStartupScript.js +127 -11
- package/dist/common/binStartupScript.js.map +1 -0
- package/dist/common/binStartupScript.mjs +135 -0
- package/dist/common/binStartupScript.mjs.map +1 -0
- package/dist/common/cleanEnvironmentVariables.d.mts +3 -0
- package/dist/common/cleanEnvironmentVariables.d.ts +3 -1
- package/dist/common/cleanEnvironmentVariables.js +30 -7
- package/dist/common/cleanEnvironmentVariables.js.map +1 -0
- package/dist/common/cleanEnvironmentVariables.mjs +8 -0
- package/dist/common/cleanEnvironmentVariables.mjs.map +1 -0
- package/dist/common/constants.d.mts +13 -0
- package/dist/common/constants.d.ts +13 -10
- package/dist/common/constants.js +58 -14
- package/dist/common/constants.js.map +1 -0
- package/dist/common/constants.mjs +28 -0
- package/dist/common/constants.mjs.map +1 -0
- package/dist/common/contextStorageStateHelpers.d.mts +24 -0
- package/dist/common/contextStorageStateHelpers.d.ts +8 -5
- package/dist/common/contextStorageStateHelpers.js +51 -23
- package/dist/common/contextStorageStateHelpers.js.map +1 -0
- package/dist/common/contextStorageStateHelpers.mjs +10 -0
- package/dist/common/contextStorageStateHelpers.mjs.map +1 -0
- package/dist/common/jwtTokenManager.d.mts +19 -0
- package/dist/common/jwtTokenManager.d.ts +6 -4
- package/dist/common/jwtTokenManager.js +112 -40
- package/dist/common/jwtTokenManager.js.map +1 -0
- package/dist/common/jwtTokenManager.mjs +11 -0
- package/dist/common/jwtTokenManager.mjs.map +1 -0
- package/dist/common/runApi/index.d.mts +11 -0
- package/dist/common/runApi/index.d.ts +10 -10
- package/dist/common/runApi/index.js +1776 -93
- package/dist/common/runApi/index.js.map +1 -0
- package/dist/common/runApi/index.mjs +18 -0
- package/dist/common/runApi/index.mjs.map +1 -0
- package/dist/common/settingsSchema.d.mts +540 -0
- package/dist/common/settingsSchema.d.ts +58 -51
- package/dist/common/settingsSchema.js +55 -20
- package/dist/common/settingsSchema.js.map +1 -0
- package/dist/common/settingsSchema.mjs +10 -0
- package/dist/common/settingsSchema.mjs.map +1 -0
- package/dist/common/telemetry.d.mts +6 -0
- package/dist/common/telemetry.d.ts +6 -3
- package/dist/common/telemetry.js +41 -9
- package/dist/common/telemetry.js.map +1 -0
- package/dist/common/telemetry.mjs +31 -0
- package/dist/common/telemetry.mjs.map +1 -0
- package/dist/export.d-BAUMB-lG.d.mts +140 -0
- package/dist/export.d-BAUMB-lG.d.ts +140 -0
- package/dist/index.d.mts +6 -0
- package/dist/index.d.ts +6 -5
- package/dist/index.js +783 -98
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +47 -0
- package/dist/index.mjs.map +1 -0
- package/dist/runtime/index.d.mts +168 -0
- package/dist/runtime/index.d.ts +168 -10
- package/dist/runtime/index.js +779 -88
- package/dist/runtime/index.js.map +1 -0
- package/dist/runtime/index.mjs +42 -0
- package/dist/runtime/index.mjs.map +1 -0
- package/package.json +78 -23
- package/.babelrc +0 -21
- package/.eslintignore +0 -10
- package/.eslintrc.js +0 -39
- package/InterfaceTemplate/__utils.ts +0 -61
- package/InterfaceTemplate/index.playwright.ts +0 -6
- package/WebTemplate.zip +0 -0
- package/dist/commands/api/run.d.ts +0 -6
- package/dist/commands/api/run.js +0 -119
- package/dist/commands/auth-sessions/load.d.ts +0 -2
- package/dist/commands/auth-sessions/load.js +0 -35
- package/dist/commands/auth-sessions/run-check.d.ts +0 -2
- package/dist/commands/auth-sessions/run-check.js +0 -74
- package/dist/commands/auth-sessions/run-create.d.ts +0 -2
- package/dist/commands/auth-sessions/run-create.js +0 -78
- package/dist/commands/browser/save-state.d.ts +0 -2
- package/dist/commands/browser/save-state.js +0 -17
- package/dist/commands/browser/start-browser.d.ts +0 -2
- package/dist/commands/browser/start-browser.js +0 -14
- package/dist/commands/build.d.ts +0 -1
- package/dist/commands/build.js +0 -84
- package/dist/commands/common/browserUtils.d.ts +0 -14
- package/dist/commands/common/browserUtils.js +0 -58
- package/dist/commands/common/getFirstLineNumber.d.ts +0 -9
- package/dist/commands/common/getFirstLineNumber.js +0 -101
- package/dist/commands/common/getFirstLineNumber.test.js +0 -228
- package/dist/commands/common/projectExclusions.d.ts +0 -2
- package/dist/commands/common/projectExclusions.js +0 -8
- package/dist/commands/common/sendMessageToClient.d.ts +0 -1
- package/dist/commands/common/sendMessageToClient.js +0 -10
- package/dist/commands/common/tsNodeImport.d.ts +0 -2
- package/dist/commands/common/tsNodeImport.js +0 -43
- package/dist/commands/common/utils/fileUtils.d.ts +0 -6
- package/dist/commands/common/utils/fileUtils.js +0 -33
- package/dist/commands/common/utils/settings.d.ts +0 -2
- package/dist/commands/common/utils/settings.js +0 -31
- package/dist/commands/common/utils/template.d.ts +0 -2
- package/dist/commands/common/utils/template.js +0 -31
- package/dist/commands/common/utils/unixSocket.d.ts +0 -23
- package/dist/commands/common/utils/unixSocket.js +0 -87
- package/dist/commands/get-headless-user-agent.d.ts +0 -1
- package/dist/commands/get-headless-user-agent.js +0 -18
- package/dist/commands/intuned-cli/commands/attempt.command.d.ts +0 -1
- package/dist/commands/intuned-cli/commands/attempt.command.js +0 -8
- package/dist/commands/intuned-cli/commands/attempt_api.command.d.ts +0 -1
- package/dist/commands/intuned-cli/commands/attempt_api.command.js +0 -30
- package/dist/commands/intuned-cli/commands/attempt_authsession.command.d.ts +0 -1
- package/dist/commands/intuned-cli/commands/attempt_authsession.command.js +0 -8
- package/dist/commands/intuned-cli/commands/attempt_authsession_check.command.d.ts +0 -1
- package/dist/commands/intuned-cli/commands/attempt_authsession_check.command.js +0 -19
- package/dist/commands/intuned-cli/commands/attempt_authsession_create.command.d.ts +0 -1
- package/dist/commands/intuned-cli/commands/attempt_authsession_create.command.js +0 -24
- package/dist/commands/intuned-cli/commands/authsession.command.d.ts +0 -1
- package/dist/commands/intuned-cli/commands/authsession.command.js +0 -8
- package/dist/commands/intuned-cli/commands/authsession_record.command.d.ts +0 -1
- package/dist/commands/intuned-cli/commands/authsession_record.command.js +0 -32
- package/dist/commands/intuned-cli/commands/authsession_scaffold.command.d.ts +0 -1
- package/dist/commands/intuned-cli/commands/authsession_scaffold.command.js +0 -16
- package/dist/commands/intuned-cli/commands/build.command.d.ts +0 -1
- package/dist/commands/intuned-cli/commands/build.command.js +0 -12
- package/dist/commands/intuned-cli/commands/command.d.ts +0 -2
- package/dist/commands/intuned-cli/commands/command.js +0 -9
- package/dist/commands/intuned-cli/commands/deploy.command.d.ts +0 -1
- package/dist/commands/intuned-cli/commands/deploy.command.js +0 -42
- package/dist/commands/intuned-cli/commands/index.d.ts +0 -18
- package/dist/commands/intuned-cli/commands/index.js +0 -203
- package/dist/commands/intuned-cli/commands/provision.command.d.ts +0 -13
- package/dist/commands/intuned-cli/commands/provision.command.js +0 -50
- package/dist/commands/intuned-cli/commands/run.command.d.ts +0 -1
- package/dist/commands/intuned-cli/commands/run.command.js +0 -8
- package/dist/commands/intuned-cli/commands/run_api.command.d.ts +0 -1
- package/dist/commands/intuned-cli/commands/run_api.command.js +0 -46
- package/dist/commands/intuned-cli/commands/run_authsession.command.d.ts +0 -31
- package/dist/commands/intuned-cli/commands/run_authsession.command.js +0 -17
- package/dist/commands/intuned-cli/commands/run_authsession_create.command.d.ts +0 -1
- package/dist/commands/intuned-cli/commands/run_authsession_create.command.js +0 -35
- package/dist/commands/intuned-cli/commands/run_authsession_update.command.d.ts +0 -1
- package/dist/commands/intuned-cli/commands/run_authsession_update.command.js +0 -35
- package/dist/commands/intuned-cli/commands/run_authsession_validate.command.d.ts +0 -1
- package/dist/commands/intuned-cli/commands/run_authsession_validate.command.js +0 -33
- package/dist/commands/intuned-cli/commands/types.d.ts +0 -35
- package/dist/commands/intuned-cli/commands/types.js +0 -31
- package/dist/commands/intuned-cli/constants/index.d.ts +0 -17
- package/dist/commands/intuned-cli/constants/index.js +0 -25
- package/dist/commands/intuned-cli/controller/__test__/api.test.js +0 -398
- package/dist/commands/intuned-cli/controller/__test__/authSession.test.js +0 -1060
- package/dist/commands/intuned-cli/controller/api.d.ts +0 -42
- package/dist/commands/intuned-cli/controller/api.js +0 -194
- package/dist/commands/intuned-cli/controller/authSession.d.ts +0 -209
- package/dist/commands/intuned-cli/controller/authSession.js +0 -424
- package/dist/commands/intuned-cli/controller/build.d.ts +0 -1
- package/dist/commands/intuned-cli/controller/build.js +0 -36
- package/dist/commands/intuned-cli/controller/deploy.d.ts +0 -5
- package/dist/commands/intuned-cli/controller/deploy.js +0 -318
- package/dist/commands/intuned-cli/controller/index.d.ts +0 -1
- package/dist/commands/intuned-cli/controller/index.js +0 -46
- package/dist/commands/intuned-cli/controller/provision.d.ts +0 -21
- package/dist/commands/intuned-cli/controller/provision.js +0 -300
- package/dist/commands/intuned-cli/controller/scaffold.d.ts +0 -1
- package/dist/commands/intuned-cli/controller/scaffold.js +0 -77
- package/dist/commands/intuned-cli/helpers/__test__/browser.test.js +0 -115
- package/dist/commands/intuned-cli/helpers/__test__/tracing.test.js +0 -41
- package/dist/commands/intuned-cli/helpers/api.d.ts +0 -3
- package/dist/commands/intuned-cli/helpers/api.js +0 -16
- package/dist/commands/intuned-cli/helpers/auth.d.ts +0 -46
- package/dist/commands/intuned-cli/helpers/auth.js +0 -147
- package/dist/commands/intuned-cli/helpers/backend.d.ts +0 -8
- package/dist/commands/intuned-cli/helpers/backend.js +0 -35
- package/dist/commands/intuned-cli/helpers/browser.d.ts +0 -15
- package/dist/commands/intuned-cli/helpers/browser.js +0 -64
- package/dist/commands/intuned-cli/helpers/context.d.ts +0 -3
- package/dist/commands/intuned-cli/helpers/context.js +0 -33
- package/dist/commands/intuned-cli/helpers/errors.d.ts +0 -16
- package/dist/commands/intuned-cli/helpers/errors.js +0 -44
- package/dist/commands/intuned-cli/helpers/index.d.ts +0 -12
- package/dist/commands/intuned-cli/helpers/index.js +0 -137
- package/dist/commands/intuned-cli/helpers/intunedJson.d.ts +0 -39
- package/dist/commands/intuned-cli/helpers/intunedJson.js +0 -20
- package/dist/commands/intuned-cli/helpers/prompts.d.ts +0 -3
- package/dist/commands/intuned-cli/helpers/prompts.js +0 -71
- package/dist/commands/intuned-cli/helpers/proxy.d.ts +0 -5
- package/dist/commands/intuned-cli/helpers/proxy.js +0 -23
- package/dist/commands/intuned-cli/helpers/terminal.d.ts +0 -5
- package/dist/commands/intuned-cli/helpers/terminal.js +0 -13
- package/dist/commands/intuned-cli/helpers/timeout.d.ts +0 -1
- package/dist/commands/intuned-cli/helpers/timeout.js +0 -23
- package/dist/commands/intuned-cli/helpers/traces.d.ts +0 -2
- package/dist/commands/intuned-cli/helpers/traces.js +0 -32
- package/dist/commands/intuned-cli/helpers/validation.d.ts +0 -2
- package/dist/commands/intuned-cli/helpers/validation.js +0 -14
- package/dist/commands/intuned-cli/helpers/wrapper.d.ts +0 -2
- package/dist/commands/intuned-cli/helpers/wrapper.js +0 -76
- package/dist/commands/intuned-cli/index.d.ts +0 -1
- package/dist/commands/intuned-cli/index.js +0 -16
- package/dist/commands/intuned-cli/main.d.ts +0 -1
- package/dist/commands/intuned-cli/main.js +0 -36
- package/dist/commands/intuned-cli/types.d.ts +0 -70
- package/dist/commands/intuned-cli/types.js +0 -22
- package/dist/commands/ts-check.d.ts +0 -2
- package/dist/commands/ts-check.js +0 -56
- package/dist/common/Logger/Logger/index.d.ts +0 -12
- package/dist/common/Logger/Logger/index.js +0 -60
- package/dist/common/Logger/Logger/types.d.ts +0 -8
- package/dist/common/Logger/Logger/types.js +0 -5
- package/dist/common/Logger/index.d.ts +0 -12
- package/dist/common/Logger/index.js +0 -60
- package/dist/common/Logger/types.d.ts +0 -8
- package/dist/common/Logger/types.js +0 -5
- package/dist/common/backendFunctions/getAuthSessionParameters.d.ts +0 -1
- package/dist/common/backendFunctions/getAuthSessionParameters.js +0 -38
- package/dist/common/extension/extensionsHelpers.d.ts +0 -11
- package/dist/common/extension/extensionsHelpers.js +0 -147
- package/dist/common/extension/intunedExtensionServer.d.ts +0 -24
- package/dist/common/extension/intunedExtensionServer.js +0 -178
- package/dist/common/extension/types.d.ts +0 -212
- package/dist/common/extension/types.js +0 -51
- package/dist/common/formatZodError.d.ts +0 -2
- package/dist/common/intunedJson.d.ts +0 -229
- package/dist/common/intunedJson.js +0 -133
- package/dist/common/launchBrowser.d.ts +0 -33
- package/dist/common/launchBrowser.js +0 -235
- package/dist/common/playwrightContext.d.ts +0 -31
- package/dist/common/playwrightContext.js +0 -150
- package/dist/common/runApi/errors.d.ts +0 -72
- package/dist/common/runApi/errors.js +0 -169
- package/dist/common/runApi/importUsingImportFunction.d.ts +0 -9
- package/dist/common/runApi/importUsingImportFunction.js +0 -46
- package/dist/common/runApi/types.d.ts +0 -830
- package/dist/common/runApi/types.js +0 -73
- package/dist/common/setupContextHook.d.ts +0 -17
- package/dist/common/setupContextHook.js +0 -22
- package/dist/runtime/RunError.d.ts +0 -5
- package/dist/runtime/RunError.js +0 -19
- package/dist/runtime/attemptStore.d.ts +0 -2
- package/dist/runtime/attemptStore.js +0 -23
- package/dist/runtime/captcha.d.ts +0 -15
- package/dist/runtime/captcha.js +0 -191
- package/dist/runtime/captcha.test.js +0 -821
- package/dist/runtime/downloadDirectory.d.ts +0 -1
- package/dist/runtime/downloadDirectory.js +0 -19
- package/dist/runtime/enums.d.js +0 -5
- package/dist/runtime/enums.d.ts +0 -11
- package/dist/runtime/enums.js +0 -18
- package/dist/runtime/executionHelpers.test.js +0 -52
- package/dist/runtime/export.d.js +0 -5
- package/dist/runtime/export.d.ts +0 -284
- package/dist/runtime/extendPayload.d.ts +0 -2
- package/dist/runtime/extendPayload.js +0 -21
- package/dist/runtime/extendTimeout.d.ts +0 -1
- package/dist/runtime/extendTimeout.js +0 -23
- package/dist/runtime/getAiGatewayConfig.d.ts +0 -10
- package/dist/runtime/getAiGatewayConfig.js +0 -16
- package/dist/runtime/getAuthSessionParameters.d.ts +0 -1
- package/dist/runtime/getAuthSessionParameters.js +0 -20
- package/dist/runtime/persistentStore.d.ts +0 -2
- package/dist/runtime/persistentStore.js +0 -37
- package/dist/runtime/persistentStore.test.js +0 -101
- package/dist/runtime/runInfo.d.ts +0 -2
- package/dist/runtime/runInfo.js +0 -21
- package/template.tsconfig.json +0 -11
- package/tsconfig.eslint.json +0 -5
- package/tsconfig.json +0 -25
- package/typedoc.json +0 -49
- /package/dist/common/assets/{browser_scripts.js → assets/browser_scripts.js} +0 -0
package/dist/runtime/index.js
CHANGED
|
@@ -1,111 +1,802 @@
|
|
|
1
|
-
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
2
28
|
|
|
3
|
-
|
|
4
|
-
|
|
29
|
+
// src/runtime/index.ts
|
|
30
|
+
var runtime_exports = {};
|
|
31
|
+
__export(runtime_exports, {
|
|
32
|
+
RunError: () => RunError,
|
|
33
|
+
attemptStore: () => attemptStore,
|
|
34
|
+
extendPayload: () => extendPayload,
|
|
35
|
+
extendTimeout: () => extendTimeout,
|
|
36
|
+
getAiGatewayConfig: () => getAiGatewayConfig,
|
|
37
|
+
getAuthSessionParameters: () => getAuthSessionParameters,
|
|
38
|
+
getDownloadDirectoryPath: () => getDownloadDirectoryPath,
|
|
39
|
+
onCaptchaEvent: () => onCaptchaEvent,
|
|
40
|
+
onceCaptchaEvent: () => onceCaptchaEvent,
|
|
41
|
+
pauseCaptchaSolver: () => pauseCaptchaSolver,
|
|
42
|
+
persistentStore: () => persistentStore,
|
|
43
|
+
removeCaptchaEventListener: () => removeCaptchaEventListener,
|
|
44
|
+
resumeCaptchaSolver: () => resumeCaptchaSolver,
|
|
45
|
+
runInfo: () => runInfo,
|
|
46
|
+
waitForCaptchaSolve: () => waitForCaptchaSolve,
|
|
47
|
+
withWaitForCaptchaSolve: () => withWaitForCaptchaSolve
|
|
5
48
|
});
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
49
|
+
module.exports = __toCommonJS(runtime_exports);
|
|
50
|
+
|
|
51
|
+
// src/common/asyncLocalStorage/index.ts
|
|
52
|
+
var import_node_async_hooks = require("async_hooks");
|
|
53
|
+
var asyncLocalStorage = new import_node_async_hooks.AsyncLocalStorage();
|
|
54
|
+
function getExecutionContext() {
|
|
55
|
+
const contextData = asyncLocalStorage.getStore();
|
|
56
|
+
return contextData;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// src/runtime/extendTimeout.ts
|
|
60
|
+
function extendTimeout() {
|
|
61
|
+
const context = getExecutionContext();
|
|
62
|
+
if (!context) {
|
|
63
|
+
throw new Error("extendTimeout failed due to an internal error.");
|
|
10
64
|
}
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
get: function () {
|
|
15
|
-
return _attemptStore.attemptStore;
|
|
65
|
+
const { timeoutInfo } = context;
|
|
66
|
+
if (!timeoutInfo) {
|
|
67
|
+
return;
|
|
16
68
|
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
enumerable: true,
|
|
20
|
-
get: function () {
|
|
21
|
-
return _extendPayload.extendPayload;
|
|
69
|
+
if (timeoutInfo.extendTimeoutCallback !== void 0) {
|
|
70
|
+
void timeoutInfo.extendTimeoutCallback().catch(() => void 0);
|
|
22
71
|
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// src/runtime/extendPayload.ts
|
|
75
|
+
function extendPayload(payload) {
|
|
76
|
+
const context = getExecutionContext();
|
|
77
|
+
if (!context) {
|
|
78
|
+
throw new Error("extendPayload failed due to an internal error.");
|
|
28
79
|
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
return _getAiGatewayConfig.getAiGatewayConfig;
|
|
80
|
+
const items = Array.isArray(payload) ? payload : [payload];
|
|
81
|
+
if (!context.extendedPayloads) {
|
|
82
|
+
context.extendedPayloads = [...items];
|
|
83
|
+
return;
|
|
34
84
|
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
85
|
+
context?.extendedPayloads.push(...items);
|
|
86
|
+
extendTimeout();
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// src/runtime/attemptStore.ts
|
|
90
|
+
var attemptStore = Object.freeze({
|
|
91
|
+
get: (key) => {
|
|
92
|
+
const context = getExecutionContext();
|
|
93
|
+
return context?.store ? context.store[key] : void 0;
|
|
94
|
+
},
|
|
95
|
+
set: (key, value) => {
|
|
96
|
+
const context = getExecutionContext();
|
|
97
|
+
if (!context) {
|
|
98
|
+
throw new Error("store.set failed due to an internal error.");
|
|
99
|
+
}
|
|
100
|
+
if (!context.store) {
|
|
101
|
+
context.store = {};
|
|
102
|
+
}
|
|
103
|
+
context.store[key] = value;
|
|
40
104
|
}
|
|
41
105
|
});
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
106
|
+
|
|
107
|
+
// src/runtime/persistentStore.ts
|
|
108
|
+
var import_zod = require("zod");
|
|
109
|
+
|
|
110
|
+
// src/common/jwtTokenManager.ts
|
|
111
|
+
var import_cross_fetch = __toESM(require("cross-fetch"));
|
|
112
|
+
var jwt = __toESM(require("jsonwebtoken"));
|
|
113
|
+
var import_neverthrow = require("neverthrow");
|
|
114
|
+
|
|
115
|
+
// src/common/constants.ts
|
|
116
|
+
var WORKSPACE_ID_ENV_VAR_KEY = "INTUNED_WORKSPACE_ID";
|
|
117
|
+
var PROJECT_ID_ENV_VAR_KEY = "INTUNED_PROJECT_ID";
|
|
118
|
+
var API_KEY_ENV_VAR_KEY = "INTUNED_API_KEY";
|
|
119
|
+
var AUTH_TOKEN_ENV_VAR_KEY = "INTUNED_AUTH_TOKEN";
|
|
120
|
+
var API_KEY_HEADER_NAME = "x-api-key";
|
|
121
|
+
var CLI_ENV_VAR_KEY = "INTUNED_CLI";
|
|
122
|
+
|
|
123
|
+
// src/common/jwtTokenManager.ts
|
|
124
|
+
var JwtTokenManager = class {
|
|
125
|
+
constructor(refreshTokenPath) {
|
|
126
|
+
this.refreshTokenPath = refreshTokenPath;
|
|
127
|
+
this._token = void 0;
|
|
46
128
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
enumerable: true,
|
|
50
|
-
get: function () {
|
|
51
|
-
return _captcha.onCaptchaEvent;
|
|
129
|
+
get token() {
|
|
130
|
+
return this._token;
|
|
52
131
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
132
|
+
// When the token is set, the schedule for renewal is issued automatically
|
|
133
|
+
// This is currently being set it two places:
|
|
134
|
+
// 1. Whenever the runner starts, initializes it from the environment variable (set whenever the api is run from the authoring IDE)
|
|
135
|
+
// 2. Whenever a published api is called to run (/api/run/*), it is set to the token received in the run request.
|
|
136
|
+
set token(newToken) {
|
|
137
|
+
if (this._token != newToken) {
|
|
138
|
+
this._token = newToken;
|
|
139
|
+
void this.scheduleTokenRefresh();
|
|
140
|
+
}
|
|
58
141
|
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
142
|
+
get timeToRefresh() {
|
|
143
|
+
if (!this._token) return;
|
|
144
|
+
const payload = jwt.decode(this._token);
|
|
145
|
+
if (!payload || typeof payload == "string") return;
|
|
146
|
+
const expiry = payload.expiry;
|
|
147
|
+
if (!expiry || typeof expiry !== "number") return;
|
|
148
|
+
const timeWindow = 60 * 1e3;
|
|
149
|
+
const timeToRefresh = expiry - Date.now() - timeWindow;
|
|
150
|
+
return Math.max(timeToRefresh, timeWindow);
|
|
64
151
|
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
152
|
+
async scheduleTokenRefresh() {
|
|
153
|
+
if (process.env.RUN_ENVIRONMENT?.toLowerCase() !== "authoring") return;
|
|
154
|
+
const timeToRefresh = this.timeToRefresh;
|
|
155
|
+
if (timeToRefresh === void 0) return;
|
|
156
|
+
if (this.tokenRefreshTimeout) clearTimeout(this.tokenRefreshTimeout);
|
|
157
|
+
this.tokenRefreshTimeout = setTimeout(async () => {
|
|
158
|
+
const result = await this.refreshToken();
|
|
159
|
+
if (result && result.isErr()) {
|
|
160
|
+
console.error(`[Internal Error] ${result.error}`);
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
await this.scheduleTokenRefresh();
|
|
164
|
+
}, timeToRefresh);
|
|
70
165
|
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
166
|
+
async refreshToken() {
|
|
167
|
+
if (process.env.RUN_ENVIRONMENT?.toLowerCase() !== "authoring") return;
|
|
168
|
+
const res = await this.fetchWithToken(
|
|
169
|
+
`${this.backendFunctionsBaseUrl}/${this.refreshTokenPath}`,
|
|
170
|
+
{
|
|
171
|
+
method: "GET"
|
|
172
|
+
}
|
|
173
|
+
);
|
|
174
|
+
if (res.status === 401) {
|
|
175
|
+
return (0, import_neverthrow.err)("Unauthorized");
|
|
176
|
+
}
|
|
177
|
+
const jsonResult = await import_neverthrow.ResultAsync.fromPromise(
|
|
178
|
+
res.json(),
|
|
179
|
+
() => "not json"
|
|
180
|
+
);
|
|
181
|
+
if (jsonResult.isErr()) return;
|
|
182
|
+
const newToken = jsonResult.value.token;
|
|
183
|
+
if (newToken) this._token = newToken;
|
|
76
184
|
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
185
|
+
async fetchWithToken(...[input, init]) {
|
|
186
|
+
const headers = new Headers(init?.headers);
|
|
187
|
+
const apiKey = process.env[API_KEY_ENV_VAR_KEY];
|
|
188
|
+
if (apiKey) {
|
|
189
|
+
headers.set(API_KEY_HEADER_NAME, apiKey);
|
|
190
|
+
}
|
|
191
|
+
const token = process.env[AUTH_TOKEN_ENV_VAR_KEY];
|
|
192
|
+
if (token) {
|
|
193
|
+
headers.set("Authorization", `Bearer ${token}`);
|
|
194
|
+
}
|
|
195
|
+
if (this.token !== void 0) {
|
|
196
|
+
headers.set("Authorization", `Bearer ${this.token}`);
|
|
197
|
+
}
|
|
198
|
+
const result = await (0, import_cross_fetch.default)(input, {
|
|
199
|
+
...init,
|
|
200
|
+
headers
|
|
201
|
+
});
|
|
202
|
+
if (result.status === 401 && process.env[CLI_ENV_VAR_KEY] === "true") {
|
|
203
|
+
console.warn(
|
|
204
|
+
"Unauthorized backend function call - make sure to provision your project to Intuned to set up the correct API credentials.\nRun 'intuned provision' or see https://docs.intunedhq.com/docs/05-references/cli#provision-project for more information."
|
|
205
|
+
);
|
|
206
|
+
}
|
|
207
|
+
return result;
|
|
208
|
+
}
|
|
209
|
+
get backendFunctionsBaseUrl() {
|
|
210
|
+
try {
|
|
211
|
+
if (!process.env.FUNCTIONS_DOMAIN) {
|
|
212
|
+
throw new Error(
|
|
213
|
+
`Cannot call backend function - FUNCTIONS_DOMAIN not set`
|
|
214
|
+
);
|
|
215
|
+
}
|
|
216
|
+
const domain = process.env.FUNCTIONS_DOMAIN;
|
|
217
|
+
if (!process.env[WORKSPACE_ID_ENV_VAR_KEY]) {
|
|
218
|
+
throw new Error(
|
|
219
|
+
`Cannot call backend function - ${WORKSPACE_ID_ENV_VAR_KEY} not set`
|
|
220
|
+
);
|
|
221
|
+
}
|
|
222
|
+
const workspaceId = process.env[WORKSPACE_ID_ENV_VAR_KEY];
|
|
223
|
+
if (!process.env[PROJECT_ID_ENV_VAR_KEY] && !process.env.INTUNED_INTEGRATION_ID) {
|
|
224
|
+
throw new Error(
|
|
225
|
+
`Cannot call backend function - ${PROJECT_ID_ENV_VAR_KEY} or INTUNED_INTEGRATION_ID not set`
|
|
226
|
+
);
|
|
227
|
+
}
|
|
228
|
+
const projectId = process.env.INTUNED_INTEGRATION_ID ?? process.env[PROJECT_ID_ENV_VAR_KEY];
|
|
229
|
+
return `${domain}/api/${workspaceId}/functions/${projectId}`;
|
|
230
|
+
} catch (e) {
|
|
231
|
+
if (process.env[CLI_ENV_VAR_KEY] === "true") {
|
|
232
|
+
throw new Error(
|
|
233
|
+
`API credentials not set - make sure to provision your project to Intuned to set up the correct API credentials.
|
|
234
|
+
Run 'intuned provision' or see https://docs.intunedhq.com/docs/05-references/cli#provision-project for more information.
|
|
235
|
+
Original error: ${e.message}`
|
|
236
|
+
);
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
};
|
|
241
|
+
var backendFunctionsTokenManager = new JwtTokenManager(
|
|
242
|
+
`refreshBackendFunctionsToken`
|
|
243
|
+
);
|
|
244
|
+
backendFunctionsTokenManager.token = process.env.INTUNED_AUTHORING_SESSION_BACKEND_FUNCTIONS_TOKEN;
|
|
245
|
+
function callBackendFunctionWithToken(path2, init) {
|
|
246
|
+
return backendFunctionsTokenManager.fetchWithToken(
|
|
247
|
+
`${backendFunctionsTokenManager.backendFunctionsBaseUrl}/${path2}`,
|
|
248
|
+
init
|
|
249
|
+
);
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
// src/runtime/persistentStore.ts
|
|
253
|
+
var forbiddenCharacters = /[:#]/g;
|
|
254
|
+
var keySchema = import_zod.z.string().min(1, "Key must be at least 1 character long").refine(
|
|
255
|
+
(key) => (key.match(forbiddenCharacters)?.length ?? 0) === 0,
|
|
256
|
+
'Key cannot contain the following characters: ":" or "#"'
|
|
257
|
+
);
|
|
258
|
+
var persistentStore = Object.freeze({
|
|
259
|
+
get: async (key) => {
|
|
260
|
+
const parsedKey = keySchema.parse(key);
|
|
261
|
+
const response = await callBackendFunctionWithToken(
|
|
262
|
+
`kv-store/${parsedKey}`,
|
|
263
|
+
{
|
|
264
|
+
method: "GET"
|
|
265
|
+
}
|
|
266
|
+
);
|
|
267
|
+
const json = await response.json();
|
|
268
|
+
if (!response.ok) {
|
|
269
|
+
throw new Error(json.message);
|
|
270
|
+
}
|
|
271
|
+
return json.value;
|
|
272
|
+
},
|
|
273
|
+
set: async (key, value) => {
|
|
274
|
+
const keyResult = keySchema.parse(key);
|
|
275
|
+
const response = await callBackendFunctionWithToken(
|
|
276
|
+
`kv-store/${keyResult}`,
|
|
277
|
+
{
|
|
278
|
+
method: "PUT",
|
|
279
|
+
body: JSON.stringify(value),
|
|
280
|
+
headers: {
|
|
281
|
+
"Content-Type": "application/json"
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
);
|
|
285
|
+
const json = await response.json();
|
|
286
|
+
if (!response.ok) {
|
|
287
|
+
throw new Error(json.message);
|
|
288
|
+
}
|
|
82
289
|
}
|
|
83
290
|
});
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
291
|
+
|
|
292
|
+
// src/runtime/getAuthSessionParameters.ts
|
|
293
|
+
async function getAuthSessionParameters() {
|
|
294
|
+
const context = getExecutionContext();
|
|
295
|
+
if (!context) {
|
|
296
|
+
throw new Error(
|
|
297
|
+
"getAuthSessionParameters failed due to an internal error (context was not found)."
|
|
298
|
+
);
|
|
88
299
|
}
|
|
300
|
+
const { getAuthSessionParameters: getAuthSessionParameters2 } = context;
|
|
301
|
+
if (!getAuthSessionParameters2) {
|
|
302
|
+
throw new Error(
|
|
303
|
+
"getAuthSessionParameters failed due to an internal error (helper was not found on context)."
|
|
304
|
+
);
|
|
305
|
+
}
|
|
306
|
+
return await getAuthSessionParameters2();
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
// src/runtime/runInfo.ts
|
|
310
|
+
function runInfo() {
|
|
311
|
+
const context = getExecutionContext();
|
|
312
|
+
if (!context) {
|
|
313
|
+
return {
|
|
314
|
+
runEnvironment: "IDE" /* IDE */
|
|
315
|
+
// runType: RunType.SYNC,
|
|
316
|
+
};
|
|
317
|
+
}
|
|
318
|
+
const { extendedPayloads: _extendedPayloads, ...rest } = context;
|
|
319
|
+
return rest;
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
// src/runtime/RunError.ts
|
|
323
|
+
var RunError = class _RunError extends Error {
|
|
324
|
+
constructor(message, options) {
|
|
325
|
+
super(message);
|
|
326
|
+
this.message = message;
|
|
327
|
+
this.name = "USER_GENERATED_ERROR";
|
|
328
|
+
this.options = options ?? {
|
|
329
|
+
retryable: false
|
|
330
|
+
};
|
|
331
|
+
Object.setPrototypeOf(this, _RunError.prototype);
|
|
332
|
+
}
|
|
333
|
+
};
|
|
334
|
+
new RunError("", {});
|
|
335
|
+
|
|
336
|
+
// src/common/extension/intunedExtensionServer.ts
|
|
337
|
+
var import_fastify = __toESM(require("fastify"));
|
|
338
|
+
|
|
339
|
+
// src/common/extension/types.ts
|
|
340
|
+
var import_zod2 = require("zod");
|
|
341
|
+
var captchaTypeSchema = import_zod2.z.enum([
|
|
342
|
+
"aws",
|
|
343
|
+
"cloudflare",
|
|
344
|
+
"customcaptcha",
|
|
345
|
+
"funcaptcha",
|
|
346
|
+
"geetest",
|
|
347
|
+
"hcaptcha",
|
|
348
|
+
"lemincaptcha",
|
|
349
|
+
"recaptcha",
|
|
350
|
+
"textcaptcha"
|
|
351
|
+
]);
|
|
352
|
+
var captchaStatusSchema = import_zod2.z.enum([
|
|
353
|
+
"attached",
|
|
354
|
+
"solving",
|
|
355
|
+
"solved",
|
|
356
|
+
"error",
|
|
357
|
+
"detached"
|
|
358
|
+
]);
|
|
359
|
+
var captchaErrorCodeSchema = import_zod2.z.enum([
|
|
360
|
+
"HIT_LIMIT",
|
|
361
|
+
"MAX_RETRIES",
|
|
362
|
+
"UNEXPECTED_SERVER_RESPONSE",
|
|
363
|
+
"UNEXPECTED_ERROR"
|
|
364
|
+
]);
|
|
365
|
+
var captchaErrorSchema = import_zod2.z.object({
|
|
366
|
+
code: captchaErrorCodeSchema,
|
|
367
|
+
error: import_zod2.z.unknown().optional()
|
|
89
368
|
});
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
369
|
+
var captchaBaseSchema = import_zod2.z.object({
|
|
370
|
+
id: import_zod2.z.string().min(1),
|
|
371
|
+
tabId: import_zod2.z.number().int().positive(),
|
|
372
|
+
type: captchaTypeSchema,
|
|
373
|
+
retryCount: import_zod2.z.number().int().nonnegative().optional()
|
|
374
|
+
});
|
|
375
|
+
var captchaNonErrorSchema = captchaBaseSchema.extend({
|
|
376
|
+
status: captchaStatusSchema.exclude(["error"])
|
|
377
|
+
});
|
|
378
|
+
var captchaErrorStatusSchema = captchaBaseSchema.extend({
|
|
379
|
+
status: import_zod2.z.literal("error"),
|
|
380
|
+
error: captchaErrorSchema
|
|
381
|
+
});
|
|
382
|
+
var captchaSchema = import_zod2.z.discriminatedUnion("status", [
|
|
383
|
+
captchaBaseSchema.extend({
|
|
384
|
+
status: import_zod2.z.literal("attached")
|
|
385
|
+
}),
|
|
386
|
+
captchaBaseSchema.extend({
|
|
387
|
+
status: import_zod2.z.literal("solving")
|
|
388
|
+
}),
|
|
389
|
+
captchaBaseSchema.extend({
|
|
390
|
+
status: import_zod2.z.literal("solved")
|
|
391
|
+
}),
|
|
392
|
+
captchaBaseSchema.extend({
|
|
393
|
+
status: import_zod2.z.literal("detached")
|
|
394
|
+
}),
|
|
395
|
+
captchaErrorStatusSchema
|
|
396
|
+
]);
|
|
397
|
+
var CaptchaSolveError = class extends Error {
|
|
398
|
+
constructor(message, error) {
|
|
399
|
+
super(message);
|
|
400
|
+
this.error = error;
|
|
401
|
+
this.name = "CaptchaSolveError";
|
|
402
|
+
}
|
|
403
|
+
};
|
|
404
|
+
var TimeoutError = class extends Error {
|
|
405
|
+
constructor(message) {
|
|
406
|
+
super(message);
|
|
407
|
+
this.name = "TimeoutError";
|
|
94
408
|
}
|
|
409
|
+
};
|
|
410
|
+
|
|
411
|
+
// src/commands/common/utils/fileUtils.ts
|
|
412
|
+
var path = __toESM(require("path"));
|
|
413
|
+
var fs = __toESM(require("fs-extra"));
|
|
414
|
+
var import_dotenv = __toESM(require("dotenv"));
|
|
415
|
+
import_dotenv.default.config();
|
|
416
|
+
function getFullPathInProject(...paths) {
|
|
417
|
+
return path.resolve(process.cwd(), process.env.ROOT || "./", ...paths);
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
// src/common/settingsSchema.ts
|
|
421
|
+
var z3 = __toESM(require("zod"));
|
|
422
|
+
var baseCaptchaSchema = z3.object({
|
|
423
|
+
enabled: z3.boolean()
|
|
424
|
+
});
|
|
425
|
+
var customCaptchaSchema = baseCaptchaSchema.extend({
|
|
426
|
+
imageLocators: z3.array(z3.string()).min(1, "At least one image locator is required"),
|
|
427
|
+
submitLocators: z3.array(z3.string()).min(1, "At least one submit locator is required"),
|
|
428
|
+
inputLocators: z3.array(z3.string()).min(1, "At least one input locator is required")
|
|
429
|
+
});
|
|
430
|
+
var textCaptchaSchema = baseCaptchaSchema.extend({
|
|
431
|
+
labelLocators: z3.array(z3.string()).min(1, "At least one image locator is required"),
|
|
432
|
+
submitLocators: z3.array(z3.string()).min(1, "At least one submit locator is required"),
|
|
433
|
+
inputLocators: z3.array(z3.string()).min(1, "At least one input locator is required")
|
|
95
434
|
});
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
435
|
+
var captchaSolverSolveSettingsSchema = z3.object({
|
|
436
|
+
autoSolve: z3.boolean().default(true),
|
|
437
|
+
solveDelay: z3.number().min(0).default(2e3),
|
|
438
|
+
maxRetries: z3.number().min(0).default(3),
|
|
439
|
+
timeout: z3.number().min(0).default(3e4)
|
|
440
|
+
});
|
|
441
|
+
var captchaSolverSettingsSchema = z3.object({
|
|
442
|
+
enabled: z3.boolean().default(false),
|
|
443
|
+
port: z3.number().int().min(1).max(65535).optional(),
|
|
444
|
+
cloudflare: baseCaptchaSchema.optional(),
|
|
445
|
+
googleRecaptchaV2: baseCaptchaSchema.optional(),
|
|
446
|
+
googleRecaptchaV3: baseCaptchaSchema.optional(),
|
|
447
|
+
awscaptcha: baseCaptchaSchema.optional(),
|
|
448
|
+
hcaptcha: baseCaptchaSchema.optional(),
|
|
449
|
+
funcaptcha: baseCaptchaSchema.optional(),
|
|
450
|
+
geetest: baseCaptchaSchema.optional(),
|
|
451
|
+
lemin: baseCaptchaSchema.optional(),
|
|
452
|
+
customCaptcha: customCaptchaSchema.optional(),
|
|
453
|
+
text: textCaptchaSchema.optional(),
|
|
454
|
+
settings: captchaSolverSolveSettingsSchema.default(
|
|
455
|
+
captchaSolverSolveSettingsSchema.parse({})
|
|
456
|
+
)
|
|
457
|
+
}).default({});
|
|
458
|
+
var authSessionsSchema = z3.object({
|
|
459
|
+
enabled: z3.boolean()
|
|
460
|
+
}).optional().default({
|
|
461
|
+
enabled: false
|
|
462
|
+
});
|
|
463
|
+
var stealthModeSchema = z3.object({
|
|
464
|
+
enabled: z3.boolean()
|
|
465
|
+
}).optional().default({
|
|
466
|
+
enabled: false
|
|
467
|
+
});
|
|
468
|
+
var settingsSchema = z3.object({
|
|
469
|
+
authSessions: authSessionsSchema,
|
|
470
|
+
stealthMode: stealthModeSchema,
|
|
471
|
+
captchaSolver: captchaSolverSettingsSchema.optional()
|
|
472
|
+
});
|
|
473
|
+
|
|
474
|
+
// src/commands/common/utils/settings.ts
|
|
475
|
+
var import_promises = require("fs/promises");
|
|
476
|
+
async function getSettings() {
|
|
477
|
+
const settingsFilePath = getFullPathInProject("Intuned.json");
|
|
478
|
+
const settings = await (0, import_promises.readFile)(settingsFilePath, { encoding: "utf-8" });
|
|
479
|
+
if (settings) {
|
|
480
|
+
const parsed = settingsSchema.safeParse(JSON.parse(settings));
|
|
481
|
+
if (parsed.success) {
|
|
482
|
+
return parsed.data;
|
|
483
|
+
} else {
|
|
484
|
+
throw new Error(parsed.error.message);
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
return {
|
|
488
|
+
authSessions: { enabled: false },
|
|
489
|
+
stealthMode: { enabled: false }
|
|
490
|
+
};
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
// src/common/extension/extensionsHelpers.ts
|
|
494
|
+
var import_portfinder = require("portfinder");
|
|
495
|
+
var INTUNED_WORKER = "intunedWorker.js";
|
|
496
|
+
var captchaSolverSettings = null;
|
|
497
|
+
async function getIntunedCaptchaExtensionPort() {
|
|
498
|
+
if (process.env.INTUNED_CAPTCHA_EXTENSION_PORT) {
|
|
499
|
+
return parseInt(process.env.INTUNED_CAPTCHA_EXTENSION_PORT, 10);
|
|
500
|
+
}
|
|
501
|
+
return await (0, import_portfinder.getPort)({});
|
|
502
|
+
}
|
|
503
|
+
async function resolveCaptchaSolverSettings(input) {
|
|
504
|
+
const parsed = captchaSolverSettingsSchema.parse(input || {});
|
|
505
|
+
if (!parsed.port) {
|
|
506
|
+
parsed.port = await getIntunedCaptchaExtensionPort();
|
|
507
|
+
}
|
|
508
|
+
return parsed;
|
|
509
|
+
}
|
|
510
|
+
function getIntunedExtensionPath() {
|
|
511
|
+
return process.env.INTUNED_EXTENSION_PATH;
|
|
512
|
+
}
|
|
513
|
+
async function isIntunedExtensionEnabled() {
|
|
514
|
+
const path2 = getIntunedExtensionPath();
|
|
515
|
+
if (!path2) {
|
|
516
|
+
return false;
|
|
517
|
+
}
|
|
518
|
+
const captchaSolverSettings2 = await getIntunedCaptchaSolverSettings();
|
|
519
|
+
return captchaSolverSettings2.enabled;
|
|
520
|
+
}
|
|
521
|
+
async function getIntunedExtensionWorker(context) {
|
|
522
|
+
if (!await isIntunedExtensionEnabled()) {
|
|
523
|
+
return null;
|
|
524
|
+
}
|
|
525
|
+
let attemptCount = 0;
|
|
526
|
+
while (attemptCount < 4) {
|
|
527
|
+
const intunedServiceWorker = context.serviceWorkers().find((serviceWorker) => serviceWorker.url().includes(INTUNED_WORKER));
|
|
528
|
+
if (intunedServiceWorker) {
|
|
529
|
+
return intunedServiceWorker;
|
|
530
|
+
}
|
|
531
|
+
try {
|
|
532
|
+
await context.waitForEvent("serviceworker", { timeout: 3e3 });
|
|
533
|
+
} catch (err2) {
|
|
534
|
+
console.log(`Error accessing service workers (attempt ${attemptCount})`);
|
|
535
|
+
}
|
|
536
|
+
attemptCount++;
|
|
537
|
+
}
|
|
538
|
+
console.error("Failed to get intuned worker after 5 attmepts");
|
|
539
|
+
return null;
|
|
540
|
+
}
|
|
541
|
+
async function getIntunedCaptchaSolverSettings() {
|
|
542
|
+
if (captchaSolverSettings) {
|
|
543
|
+
return captchaSolverSettings;
|
|
544
|
+
}
|
|
545
|
+
const settings = await getSettings();
|
|
546
|
+
captchaSolverSettings = await resolveCaptchaSolverSettings(
|
|
547
|
+
settings.captchaSolver
|
|
548
|
+
);
|
|
549
|
+
return captchaSolverSettings;
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
// src/common/extension/intunedExtensionServer.ts
|
|
553
|
+
var extensionServerSingleton = null;
|
|
554
|
+
function getIntunedExtensionServer() {
|
|
555
|
+
if (!extensionServerSingleton) {
|
|
556
|
+
throw new Error("Intuned Extension Server is not initialized.");
|
|
557
|
+
}
|
|
558
|
+
return extensionServerSingleton;
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
// src/runtime/captcha.ts
|
|
562
|
+
async function withWaitForCaptchaSolve(callback, options) {
|
|
563
|
+
const {
|
|
564
|
+
page,
|
|
565
|
+
timeoutInMs = 1e4,
|
|
566
|
+
settleDurationMs = 5e3,
|
|
567
|
+
waitForNetworkSettled = true
|
|
568
|
+
} = options;
|
|
569
|
+
console.error(
|
|
570
|
+
`Starting captcha solve wait (timeout=${timeoutInMs}ms, settleDuration=${settleDurationMs}ms, waitForNetworkSettled=${waitForNetworkSettled})`
|
|
571
|
+
);
|
|
572
|
+
const extensionServer = getIntunedExtensionServer();
|
|
573
|
+
let settledResolve = null;
|
|
574
|
+
let settledPromise = new Promise((resolve2) => {
|
|
575
|
+
settledResolve = resolve2;
|
|
576
|
+
});
|
|
577
|
+
let isTimeout = false;
|
|
578
|
+
let captchasAppeared = false;
|
|
579
|
+
let error = void 0;
|
|
580
|
+
let actionDone = false;
|
|
581
|
+
const getPendingCaptchas = async () => await extensionServer.getCaptchas(page, "solving");
|
|
582
|
+
const hasNoPendingCaptchas = async () => !captchasAppeared || (await getPendingCaptchas()).length === 0;
|
|
583
|
+
const maybeSettle = async () => {
|
|
584
|
+
if (await hasNoPendingCaptchas()) {
|
|
585
|
+
settledResolve?.();
|
|
586
|
+
}
|
|
587
|
+
};
|
|
588
|
+
const onCaptchaUpdate = async (_captcha) => {
|
|
589
|
+
const solvingCaptchas = await extensionServer.getCaptchas(page, "solving");
|
|
590
|
+
const errorCaptchas = await extensionServer.getCaptchas(page, "error");
|
|
591
|
+
console.error(
|
|
592
|
+
`Captcha update received: solving=${solvingCaptchas.length}, errors=${errorCaptchas.length}`
|
|
593
|
+
);
|
|
594
|
+
if (solvingCaptchas.length > 0) {
|
|
595
|
+
captchasAppeared = true;
|
|
596
|
+
console.error(
|
|
597
|
+
`Captchas detected: ${solvingCaptchas.map((c) => c.id).join(", ")}`
|
|
598
|
+
);
|
|
599
|
+
}
|
|
600
|
+
if (errorCaptchas.length > 0) {
|
|
601
|
+
error = errorCaptchas[0].error;
|
|
602
|
+
console.error(`Captcha error detected: ${error?.code}`);
|
|
603
|
+
await maybeSettle();
|
|
604
|
+
return;
|
|
605
|
+
}
|
|
606
|
+
if (solvingCaptchas.length === 0) {
|
|
607
|
+
console.error("No pending captchas, settling");
|
|
608
|
+
await maybeSettle();
|
|
609
|
+
}
|
|
610
|
+
};
|
|
611
|
+
const result = await callback(page);
|
|
612
|
+
actionDone = true;
|
|
613
|
+
if (waitForNetworkSettled) {
|
|
614
|
+
try {
|
|
615
|
+
await page.waitForLoadState("networkidle");
|
|
616
|
+
} catch (err2) {
|
|
617
|
+
console.error(`Failed to wait for networkidle. Error: ${err2}`);
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
const timeoutPromise = new Promise((resolve2) => {
|
|
621
|
+
setTimeout(() => {
|
|
622
|
+
isTimeout = true;
|
|
623
|
+
console.error("Captcha solve timeout reached");
|
|
624
|
+
settledResolve?.();
|
|
625
|
+
resolve2();
|
|
626
|
+
}, timeoutInMs);
|
|
627
|
+
});
|
|
628
|
+
await extensionServer.subscribe(page, onCaptchaUpdate);
|
|
629
|
+
try {
|
|
630
|
+
const initialPending = await getPendingCaptchas();
|
|
631
|
+
console.error(`Found ${initialPending.length} ongoing captchas`);
|
|
632
|
+
if (initialPending.length > 0) {
|
|
633
|
+
captchasAppeared = true;
|
|
634
|
+
}
|
|
635
|
+
await maybeSettle();
|
|
636
|
+
let shouldContinue = true;
|
|
637
|
+
while (shouldContinue) {
|
|
638
|
+
await Promise.race([settledPromise, timeoutPromise]);
|
|
639
|
+
console.error(
|
|
640
|
+
`Settled event received, waiting ${settleDurationMs}ms before checking`
|
|
641
|
+
);
|
|
642
|
+
await new Promise((r) => setTimeout(r, settleDurationMs));
|
|
643
|
+
if (error) {
|
|
644
|
+
console.error(`Raising captcha error: ${error.code}`);
|
|
645
|
+
throw new CaptchaSolveError(
|
|
646
|
+
`CAPTCHA Solve Error: ${error.code}`,
|
|
647
|
+
error
|
|
648
|
+
);
|
|
649
|
+
}
|
|
650
|
+
const noPendingCaptchas = await hasNoPendingCaptchas();
|
|
651
|
+
const pending = await getPendingCaptchas();
|
|
652
|
+
console.error(
|
|
653
|
+
`Check point: actionDone=${actionDone}, noPendingCaptchas=${noPendingCaptchas}, isTimeout=${isTimeout}, pendingCount=${pending.length}`
|
|
654
|
+
);
|
|
655
|
+
if (actionDone && noPendingCaptchas || isTimeout) {
|
|
656
|
+
if (isTimeout && !noPendingCaptchas) {
|
|
657
|
+
console.error(`Timeout with ${pending.length} pending captchas`);
|
|
658
|
+
throw new TimeoutError(
|
|
659
|
+
"CAPTCHA Solve timed out with pending captchas."
|
|
660
|
+
);
|
|
661
|
+
}
|
|
662
|
+
console.error("Captcha solve completed successfully");
|
|
663
|
+
shouldContinue = false;
|
|
664
|
+
} else {
|
|
665
|
+
console.error(
|
|
666
|
+
`Still have ${pending.length} pending captchas, waiting for more updates`
|
|
667
|
+
);
|
|
668
|
+
settledPromise = new Promise((resolve2) => {
|
|
669
|
+
settledResolve = resolve2;
|
|
670
|
+
});
|
|
671
|
+
}
|
|
672
|
+
}
|
|
673
|
+
return result;
|
|
674
|
+
} finally {
|
|
675
|
+
await extensionServer.unsubscribe(page, onCaptchaUpdate);
|
|
676
|
+
}
|
|
677
|
+
}
|
|
678
|
+
async function waitForCaptchaSolve(page, {
|
|
679
|
+
timeoutInMs = 1e4,
|
|
680
|
+
settleDurationMs = 5e3
|
|
681
|
+
} = {}) {
|
|
682
|
+
await withWaitForCaptchaSolve(async () => void 0, {
|
|
683
|
+
page,
|
|
684
|
+
timeoutInMs,
|
|
685
|
+
settleDurationMs,
|
|
686
|
+
waitForNetworkSettled: false
|
|
687
|
+
});
|
|
688
|
+
}
|
|
689
|
+
async function removeCaptchaEventListener(page, status, f) {
|
|
690
|
+
const extensionServer = getIntunedExtensionServer();
|
|
691
|
+
await extensionServer.unsubscribe(page, f, status);
|
|
692
|
+
}
|
|
693
|
+
async function onCaptchaEvent(page, status, f) {
|
|
694
|
+
const extensionServer = getIntunedExtensionServer();
|
|
695
|
+
await extensionServer.subscribe(page, f, status);
|
|
696
|
+
}
|
|
697
|
+
async function onceCaptchaEvent(page, status, f) {
|
|
698
|
+
const extensionServer = getIntunedExtensionServer();
|
|
699
|
+
const oneTimeHandler = async (captcha) => {
|
|
700
|
+
await extensionServer.unsubscribe(page, oneTimeHandler, status);
|
|
701
|
+
await f(captcha);
|
|
702
|
+
};
|
|
703
|
+
await extensionServer.subscribe(page, oneTimeHandler, status);
|
|
704
|
+
}
|
|
705
|
+
async function setAutoSolve(context, enabled) {
|
|
706
|
+
const worker = await getIntunedExtensionWorker(context);
|
|
707
|
+
if (!worker) {
|
|
708
|
+
if (!enabled) {
|
|
709
|
+
return;
|
|
710
|
+
}
|
|
711
|
+
throw new Error("Intuned service worker not found");
|
|
712
|
+
}
|
|
713
|
+
await worker.evaluate(
|
|
714
|
+
`
|
|
715
|
+
(enabled) => new Promise((resolve, reject) => {
|
|
716
|
+
const updateSettings = () => {
|
|
717
|
+
if (chrome?.storage?.local) {
|
|
718
|
+
chrome.storage.local.get('settings', (result) => {
|
|
719
|
+
if (chrome.runtime.lastError) {
|
|
720
|
+
reject(new Error(chrome.runtime.lastError.message));
|
|
721
|
+
return;
|
|
722
|
+
}
|
|
723
|
+
const settings = result.settings || {};
|
|
724
|
+
if (!settings.settings) {
|
|
725
|
+
settings.settings = {};
|
|
726
|
+
}
|
|
727
|
+
settings.settings.autoSolve = enabled;
|
|
728
|
+
chrome.storage.local.set({ settings }, () => {
|
|
729
|
+
if (chrome.runtime.lastError) {
|
|
730
|
+
reject(new Error(chrome.runtime.lastError.message));
|
|
731
|
+
} else {
|
|
732
|
+
resolve(true);
|
|
733
|
+
}
|
|
734
|
+
});
|
|
735
|
+
});
|
|
736
|
+
} else {
|
|
737
|
+
setTimeout(updateSettings, 50);
|
|
738
|
+
}
|
|
739
|
+
};
|
|
740
|
+
updateSettings();
|
|
741
|
+
})
|
|
742
|
+
`,
|
|
743
|
+
enabled
|
|
744
|
+
);
|
|
745
|
+
}
|
|
746
|
+
async function pauseCaptchaSolver(context) {
|
|
747
|
+
if (!await isIntunedExtensionEnabled()) {
|
|
748
|
+
throw new Error(
|
|
749
|
+
"Intuned extension is not enabled. Cannot pause captcha solver."
|
|
750
|
+
);
|
|
751
|
+
}
|
|
752
|
+
await setAutoSolve(context, false);
|
|
753
|
+
}
|
|
754
|
+
async function resumeCaptchaSolver(context) {
|
|
755
|
+
if (!await isIntunedExtensionEnabled()) {
|
|
756
|
+
throw new Error(
|
|
757
|
+
"Intuned extension is not enabled. Cannot resume captcha solver."
|
|
758
|
+
);
|
|
759
|
+
}
|
|
760
|
+
await setAutoSolve(context, true);
|
|
761
|
+
}
|
|
762
|
+
|
|
763
|
+
// src/runtime/getAiGatewayConfig.ts
|
|
764
|
+
function getAiGatewayConfig() {
|
|
765
|
+
const baseUrl = `${backendFunctionsTokenManager.backendFunctionsBaseUrl}/intuned-ai-gateway`;
|
|
766
|
+
const apiKey = backendFunctionsTokenManager.token ?? process.env[API_KEY_ENV_VAR_KEY] ?? "";
|
|
767
|
+
return { baseUrl, apiKey };
|
|
768
|
+
}
|
|
769
|
+
|
|
770
|
+
// src/runtime/downloadDirectory.ts
|
|
771
|
+
var import_fs_extra = require("fs-extra");
|
|
772
|
+
function getDownloadDirectoryPath() {
|
|
773
|
+
const context = getExecutionContext();
|
|
774
|
+
if (!context) {
|
|
775
|
+
throw new Error("ExecutionContext not found");
|
|
100
776
|
}
|
|
777
|
+
const path2 = `/tmp/downloads/${context.runId}`;
|
|
778
|
+
(0, import_fs_extra.ensureDirSync)(path2, {
|
|
779
|
+
mode: 1533
|
|
780
|
+
});
|
|
781
|
+
return path2;
|
|
782
|
+
}
|
|
783
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
784
|
+
0 && (module.exports = {
|
|
785
|
+
RunError,
|
|
786
|
+
attemptStore,
|
|
787
|
+
extendPayload,
|
|
788
|
+
extendTimeout,
|
|
789
|
+
getAiGatewayConfig,
|
|
790
|
+
getAuthSessionParameters,
|
|
791
|
+
getDownloadDirectoryPath,
|
|
792
|
+
onCaptchaEvent,
|
|
793
|
+
onceCaptchaEvent,
|
|
794
|
+
pauseCaptchaSolver,
|
|
795
|
+
persistentStore,
|
|
796
|
+
removeCaptchaEventListener,
|
|
797
|
+
resumeCaptchaSolver,
|
|
798
|
+
runInfo,
|
|
799
|
+
waitForCaptchaSolve,
|
|
800
|
+
withWaitForCaptchaSolve
|
|
101
801
|
});
|
|
102
|
-
|
|
103
|
-
var _extendTimeout = require("./extendTimeout");
|
|
104
|
-
var _attemptStore = require("./attemptStore");
|
|
105
|
-
var _persistentStore = require("./persistentStore");
|
|
106
|
-
var _getAuthSessionParameters = require("./getAuthSessionParameters");
|
|
107
|
-
var _runInfo = require("./runInfo");
|
|
108
|
-
var _RunError = require("./RunError");
|
|
109
|
-
var _captcha = require("./captcha");
|
|
110
|
-
var _getAiGatewayConfig = require("./getAiGatewayConfig");
|
|
111
|
-
var _downloadDirectory = require("./downloadDirectory");
|
|
802
|
+
//# sourceMappingURL=index.js.map
|