@intuned/runtime 1.3.18-interface.7 → 1.3.18
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 +27 -0
- package/.claude/settings.local.json +7 -0
- package/.eslintignore +10 -0
- package/.eslintrc.js +39 -0
- package/InterfaceTemplate/__utils.ts +63 -0
- package/InterfaceTemplate/index.playwright.ts +6 -0
- 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 -3
- package/dist/commands/interface/run.js +139 -2047
- 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/asyncLocalStorage/index.d.ts +8 -9
- package/dist/common/asyncLocalStorage/index.js +9 -34
- package/dist/common/backendFunctions/getAuthSessionParameters.d.ts +1 -0
- package/dist/common/backendFunctions/getAuthSessionParameters.js +38 -0
- package/dist/common/binStartupScript.d.ts +1 -2
- package/dist/common/binStartupScript.js +10 -127
- package/dist/common/browserTabs.d.ts +72 -0
- package/dist/common/browserTabs.js +74 -0
- package/dist/common/cleanEnvironmentVariables.d.ts +1 -3
- package/dist/common/cleanEnvironmentVariables.js +7 -30
- package/dist/common/constants.d.ts +11 -13
- package/dist/common/constants.js +15 -58
- package/dist/common/contextStorageStateHelpers.d.ts +6 -8
- package/dist/common/contextStorageStateHelpers.js +22 -47
- 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/{chunk-NDMVGENG.mjs → common/formatZodError.js} +9 -9
- package/dist/common/intunedJson.d.ts +229 -0
- package/dist/common/intunedJson.js +132 -0
- package/dist/common/jwtTokenManager.d.ts +4 -6
- package/dist/common/jwtTokenManager.js +40 -108
- 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 +6 -9
- package/dist/common/runApi/index.js +73 -1782
- package/dist/common/settingsSchema.d.ts +6 -9
- package/dist/common/settingsSchema.js +18 -54
- package/dist/common/setupContextHook.d.ts +16 -0
- package/dist/common/setupContextHook.js +22 -0
- package/dist/common/telemetry.d.ts +3 -6
- package/dist/common/telemetry.js +8 -41
- package/dist/index.d.ts +4 -6
- package/dist/index.js +92 -784
- 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 -168
- package/dist/runtime/index.js +88 -779
- 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 +20 -68
- package/template.tsconfig.json +11 -0
- package/tsconfig.eslint.json +5 -0
- package/tsconfig.json +25 -0
- package/tsup.config.ts +12 -0
- package/typedoc.json +49 -0
- package/dist/chunk-6ZRJOUQS.mjs +0 -16
- package/dist/chunk-6ZRJOUQS.mjs.map +0 -1
- package/dist/chunk-7YL2JUTE.mjs +0 -146
- package/dist/chunk-7YL2JUTE.mjs.map +0 -1
- package/dist/chunk-B3T6RXPC.mjs +0 -794
- package/dist/chunk-B3T6RXPC.mjs.map +0 -1
- package/dist/chunk-FGV5T6SI.mjs +0 -27
- package/dist/chunk-FGV5T6SI.mjs.map +0 -1
- package/dist/chunk-G4PO5RIV.mjs +0 -85
- package/dist/chunk-G4PO5RIV.mjs.map +0 -1
- package/dist/chunk-LZOMFHX3.mjs +0 -38
- package/dist/chunk-LZOMFHX3.mjs.map +0 -1
- package/dist/chunk-NDMVGENG.mjs.map +0 -1
- package/dist/chunk-W4UX6G4X.mjs +0 -17
- package/dist/chunk-W4UX6G4X.mjs.map +0 -1
- package/dist/chunk-XC75QGFG.mjs +0 -1106
- package/dist/chunk-XC75QGFG.mjs.map +0 -1
- package/dist/chunk-XOAZ2MGA.mjs +0 -59
- package/dist/chunk-XOAZ2MGA.mjs.map +0 -1
- package/dist/commands/interface/run.d.mts +0 -3
- package/dist/commands/interface/run.js.map +0 -1
- package/dist/commands/interface/run.mjs +0 -255
- package/dist/commands/interface/run.mjs.map +0 -1
- package/dist/common/asyncLocalStorage/index.d.mts +0 -17
- package/dist/common/asyncLocalStorage/index.js.map +0 -1
- package/dist/common/asyncLocalStorage/index.mjs +0 -12
- package/dist/common/asyncLocalStorage/index.mjs.map +0 -1
- package/dist/common/binStartupScript.d.mts +0 -2
- package/dist/common/binStartupScript.js.map +0 -1
- package/dist/common/binStartupScript.mjs +0 -135
- package/dist/common/binStartupScript.mjs.map +0 -1
- package/dist/common/cleanEnvironmentVariables.d.mts +0 -3
- package/dist/common/cleanEnvironmentVariables.js.map +0 -1
- package/dist/common/cleanEnvironmentVariables.mjs +0 -8
- package/dist/common/cleanEnvironmentVariables.mjs.map +0 -1
- package/dist/common/constants.d.mts +0 -13
- package/dist/common/constants.js.map +0 -1
- package/dist/common/constants.mjs +0 -28
- package/dist/common/constants.mjs.map +0 -1
- package/dist/common/contextStorageStateHelpers.d.mts +0 -24
- package/dist/common/contextStorageStateHelpers.js.map +0 -1
- package/dist/common/contextStorageStateHelpers.mjs +0 -10
- package/dist/common/contextStorageStateHelpers.mjs.map +0 -1
- package/dist/common/jwtTokenManager.d.mts +0 -19
- package/dist/common/jwtTokenManager.js.map +0 -1
- package/dist/common/jwtTokenManager.mjs +0 -11
- package/dist/common/jwtTokenManager.mjs.map +0 -1
- package/dist/common/runApi/index.d.mts +0 -11
- package/dist/common/runApi/index.js.map +0 -1
- package/dist/common/runApi/index.mjs +0 -18
- package/dist/common/runApi/index.mjs.map +0 -1
- package/dist/common/settingsSchema.d.mts +0 -540
- package/dist/common/settingsSchema.js.map +0 -1
- package/dist/common/settingsSchema.mjs +0 -10
- package/dist/common/settingsSchema.mjs.map +0 -1
- package/dist/common/telemetry.d.mts +0 -6
- package/dist/common/telemetry.js.map +0 -1
- package/dist/common/telemetry.mjs +0 -31
- package/dist/common/telemetry.mjs.map +0 -1
- package/dist/export.d-BAUMB-lG.d.mts +0 -140
- package/dist/export.d-BAUMB-lG.d.ts +0 -140
- package/dist/index.d.mts +0 -6
- package/dist/index.js.map +0 -1
- package/dist/index.mjs +0 -47
- package/dist/index.mjs.map +0 -1
- package/dist/runtime/index.d.mts +0 -168
- package/dist/runtime/index.js.map +0 -1
- package/dist/runtime/index.mjs +0 -42
- package/dist/runtime/index.mjs.map +0 -1
- /package/dist/common/assets/{assets/browser_scripts.js → browser_scripts.js} +0 -0
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tab management utilities using CDP HTTP API.
|
|
3
|
+
*
|
|
4
|
+
* Provides functions to interact with browser tabs via Chrome DevTools Protocol HTTP endpoints.
|
|
5
|
+
* Refer to https://chromedevtools.github.io/devtools-protocol/ for the endpoints documentation.
|
|
6
|
+
* This approach is simpler than using the playwright API because it doesn't require us to create a playwright context.
|
|
7
|
+
*/
|
|
8
|
+
export interface CDPTabInfo {
|
|
9
|
+
id: string;
|
|
10
|
+
type: string;
|
|
11
|
+
title: string;
|
|
12
|
+
url: string;
|
|
13
|
+
webSocketDebuggerUrl?: string;
|
|
14
|
+
devtoolsFrontendUrl?: string;
|
|
15
|
+
faviconUrl?: string;
|
|
16
|
+
description?: string;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Fetch current tabs from CDP /json endpoint.
|
|
20
|
+
*
|
|
21
|
+
* @param cdpAddress - CDP address (e.g., "http://localhost:9222")
|
|
22
|
+
* @returns List of tab info dictionaries from CDP (filtered to only "page" type)
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* const tabs = await getCDPTabs("http://localhost:9222");
|
|
26
|
+
* // Returns:
|
|
27
|
+
* // [
|
|
28
|
+
* // {
|
|
29
|
+
* // "id": "1234",
|
|
30
|
+
* // "type": "page",
|
|
31
|
+
* // "title": "Google",
|
|
32
|
+
* // "url": "https://google.com",
|
|
33
|
+
* // ...
|
|
34
|
+
* // }
|
|
35
|
+
* // ]
|
|
36
|
+
*/
|
|
37
|
+
export declare function getCDPTabs(cdpAddress: string): Promise<CDPTabInfo[]>;
|
|
38
|
+
/**
|
|
39
|
+
* Create new tab via CDP /json/new endpoint with optional URL.
|
|
40
|
+
*
|
|
41
|
+
* @param cdpAddress - CDP address (e.g., "http://localhost:9222")
|
|
42
|
+
* @param url - Initial URL for the tab (default: "about:blank")
|
|
43
|
+
* @returns Tab info dictionary from CDP
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* const tab = await createCDPTab("http://localhost:9222", "https://google.com");
|
|
47
|
+
* // Returns:
|
|
48
|
+
* // {
|
|
49
|
+
* // "id": "1234",
|
|
50
|
+
* // "type": "page",
|
|
51
|
+
* // "title": "New Tab",
|
|
52
|
+
* // "url": "about:blank",
|
|
53
|
+
* // ...
|
|
54
|
+
* // }
|
|
55
|
+
*/
|
|
56
|
+
export declare function createCDPTab(cdpAddress: string, url?: string): Promise<CDPTabInfo>;
|
|
57
|
+
/**
|
|
58
|
+
* Close tab via CDP /json/close/{id} endpoint.
|
|
59
|
+
*
|
|
60
|
+
* @param cdpAddress - CDP address (e.g., "http://localhost:9222")
|
|
61
|
+
* @param cdpTargetId - Full CDP target ID to close
|
|
62
|
+
* @returns True if successful, False otherwise
|
|
63
|
+
*/
|
|
64
|
+
export declare function closeCDPTab(cdpAddress: string, cdpTargetId: string): Promise<boolean>;
|
|
65
|
+
/**
|
|
66
|
+
* Activate/bring to front a tab via CDP /json/activate/{id} endpoint.
|
|
67
|
+
*
|
|
68
|
+
* @param cdpAddress - CDP address (e.g., "http://localhost:9222")
|
|
69
|
+
* @param cdpTargetId - Full CDP target ID to activate
|
|
70
|
+
* @returns True if successful, False otherwise
|
|
71
|
+
*/
|
|
72
|
+
export declare function activateCDPTab(cdpAddress: string, cdpTargetId: string): Promise<boolean>;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.activateCDPTab = activateCDPTab;
|
|
7
|
+
exports.closeCDPTab = closeCDPTab;
|
|
8
|
+
exports.createCDPTab = createCDPTab;
|
|
9
|
+
exports.getCDPTabs = getCDPTabs;
|
|
10
|
+
const DEFAULT_TIMEOUT = 5000;
|
|
11
|
+
async function getCDPTabs(cdpAddress) {
|
|
12
|
+
const controller = new AbortController();
|
|
13
|
+
const timeoutId = setTimeout(() => controller.abort(), DEFAULT_TIMEOUT);
|
|
14
|
+
try {
|
|
15
|
+
const response = await fetch(`${cdpAddress}/json`, {
|
|
16
|
+
signal: controller.signal
|
|
17
|
+
});
|
|
18
|
+
if (!response.ok) {
|
|
19
|
+
throw new Error(`HTTP error! status: ${response.status}`);
|
|
20
|
+
}
|
|
21
|
+
const tabs = await response.json();
|
|
22
|
+
return tabs.filter(tab => tab.type === "page");
|
|
23
|
+
} finally {
|
|
24
|
+
clearTimeout(timeoutId);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
async function createCDPTab(cdpAddress, url = "about:blank") {
|
|
28
|
+
const controller = new AbortController();
|
|
29
|
+
const timeoutId = setTimeout(() => controller.abort(), DEFAULT_TIMEOUT);
|
|
30
|
+
try {
|
|
31
|
+
let endpoint = `${cdpAddress}/json/new`;
|
|
32
|
+
if (url && url !== "about:blank") {
|
|
33
|
+
endpoint = `${endpoint}?${url}`;
|
|
34
|
+
}
|
|
35
|
+
const response = await fetch(endpoint, {
|
|
36
|
+
method: "PUT",
|
|
37
|
+
signal: controller.signal
|
|
38
|
+
});
|
|
39
|
+
if (!response.ok) {
|
|
40
|
+
throw new Error(`HTTP error! status: ${response.status}`);
|
|
41
|
+
}
|
|
42
|
+
return await response.json();
|
|
43
|
+
} finally {
|
|
44
|
+
clearTimeout(timeoutId);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
async function closeCDPTab(cdpAddress, cdpTargetId) {
|
|
48
|
+
const controller = new AbortController();
|
|
49
|
+
const timeoutId = setTimeout(() => controller.abort(), DEFAULT_TIMEOUT);
|
|
50
|
+
try {
|
|
51
|
+
const response = await fetch(`${cdpAddress}/json/close/${cdpTargetId}`, {
|
|
52
|
+
signal: controller.signal
|
|
53
|
+
});
|
|
54
|
+
return response.status === 200;
|
|
55
|
+
} catch {
|
|
56
|
+
return false;
|
|
57
|
+
} finally {
|
|
58
|
+
clearTimeout(timeoutId);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
async function activateCDPTab(cdpAddress, cdpTargetId) {
|
|
62
|
+
const controller = new AbortController();
|
|
63
|
+
const timeoutId = setTimeout(() => controller.abort(), DEFAULT_TIMEOUT);
|
|
64
|
+
try {
|
|
65
|
+
const response = await fetch(`${cdpAddress}/json/activate/${cdpTargetId}`, {
|
|
66
|
+
signal: controller.signal
|
|
67
|
+
});
|
|
68
|
+
return response.status === 200;
|
|
69
|
+
} catch {
|
|
70
|
+
return false;
|
|
71
|
+
} finally {
|
|
72
|
+
clearTimeout(timeoutId);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
@@ -1,39 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __export = (target, all) => {
|
|
6
|
-
for (var name in all)
|
|
7
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
-
};
|
|
9
|
-
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
-
}
|
|
15
|
-
return to;
|
|
16
|
-
};
|
|
17
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
1
|
+
"use strict";
|
|
18
2
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
__export(cleanEnvironmentVariables_exports, {
|
|
22
|
-
cleanEnvironmentVariables: () => cleanEnvironmentVariables
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
23
5
|
});
|
|
24
|
-
|
|
6
|
+
exports.cleanEnvironmentVariables = cleanEnvironmentVariables;
|
|
25
7
|
function cleanEnvironmentVariables() {
|
|
26
|
-
Object.keys(process.env).filter(
|
|
8
|
+
Object.keys(process.env).filter(i => {
|
|
27
9
|
if (i.toLocaleLowerCase().startsWith("npm")) {
|
|
28
10
|
return true;
|
|
29
11
|
}
|
|
30
12
|
if (i.toLocaleLowerCase().startsWith("fly") && i !== "FLY_ALLOC_ID") {
|
|
31
13
|
return true;
|
|
32
14
|
}
|
|
33
|
-
}).forEach(
|
|
34
|
-
}
|
|
35
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
36
|
-
0 && (module.exports = {
|
|
37
|
-
cleanEnvironmentVariables
|
|
38
|
-
});
|
|
39
|
-
//# sourceMappingURL=cleanEnvironmentVariables.js.map
|
|
15
|
+
}).forEach(i => delete process.env[i]);
|
|
16
|
+
}
|
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
declare const API_FOLDER_NAME = "api";
|
|
2
|
-
declare const AUTH_SESSIONS_FOLDER_NAME = "auth-sessions";
|
|
3
|
-
declare const AUTH_SESSIONS_INSTANCES_FOLDER_NAME = "auth-sessions-instances";
|
|
4
|
-
declare const WORKSPACE_ID_ENV_VAR_KEY = "INTUNED_WORKSPACE_ID";
|
|
5
|
-
declare const EXTENSION_PATH_ENV_VAR_KEY = "INTUNED_EXTENSION_PATH";
|
|
6
|
-
declare const PROJECT_ID_ENV_VAR_KEY = "INTUNED_PROJECT_ID";
|
|
7
|
-
declare const API_KEY_ENV_VAR_KEY = "INTUNED_API_KEY";
|
|
8
|
-
declare const AUTH_TOKEN_ENV_VAR_KEY = "INTUNED_AUTH_TOKEN";
|
|
9
|
-
declare const API_KEY_HEADER_NAME = "x-api-key";
|
|
10
|
-
declare const API_BASE_URL_ENV_VAR_KEY = "INTUNED_API_BASE_URL";
|
|
11
|
-
declare const CLI_ENV_VAR_KEY = "INTUNED_CLI";
|
|
12
|
-
|
|
13
|
-
export { API_BASE_URL_ENV_VAR_KEY, API_FOLDER_NAME, API_KEY_ENV_VAR_KEY, API_KEY_HEADER_NAME, AUTH_SESSIONS_FOLDER_NAME, AUTH_SESSIONS_INSTANCES_FOLDER_NAME, AUTH_TOKEN_ENV_VAR_KEY, CLI_ENV_VAR_KEY, EXTENSION_PATH_ENV_VAR_KEY, PROJECT_ID_ENV_VAR_KEY, WORKSPACE_ID_ENV_VAR_KEY };
|
|
1
|
+
export declare const API_FOLDER_NAME = "api";
|
|
2
|
+
export declare const AUTH_SESSIONS_FOLDER_NAME = "auth-sessions";
|
|
3
|
+
export declare const AUTH_SESSIONS_INSTANCES_FOLDER_NAME = "auth-sessions-instances";
|
|
4
|
+
export declare const WORKSPACE_ID_ENV_VAR_KEY = "INTUNED_WORKSPACE_ID";
|
|
5
|
+
export declare const EXTENSION_PATH_ENV_VAR_KEY = "INTUNED_EXTENSION_PATH";
|
|
6
|
+
export declare const PROJECT_ID_ENV_VAR_KEY = "INTUNED_PROJECT_ID";
|
|
7
|
+
export declare const API_KEY_ENV_VAR_KEY = "INTUNED_API_KEY";
|
|
8
|
+
export declare const AUTH_TOKEN_ENV_VAR_KEY = "INTUNED_AUTH_TOKEN";
|
|
9
|
+
export declare const API_KEY_HEADER_NAME = "x-api-key";
|
|
10
|
+
export declare const API_BASE_URL_ENV_VAR_KEY = "INTUNED_API_BASE_URL";
|
|
11
|
+
export declare const CLI_ENV_VAR_KEY = "INTUNED_CLI";
|
package/dist/common/constants.js
CHANGED
|
@@ -1,60 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __export = (target, all) => {
|
|
6
|
-
for (var name in all)
|
|
7
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
-
};
|
|
9
|
-
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
-
}
|
|
15
|
-
return to;
|
|
16
|
-
};
|
|
17
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
1
|
+
"use strict";
|
|
18
2
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
__export(constants_exports, {
|
|
22
|
-
API_BASE_URL_ENV_VAR_KEY: () => API_BASE_URL_ENV_VAR_KEY,
|
|
23
|
-
API_FOLDER_NAME: () => API_FOLDER_NAME,
|
|
24
|
-
API_KEY_ENV_VAR_KEY: () => API_KEY_ENV_VAR_KEY,
|
|
25
|
-
API_KEY_HEADER_NAME: () => API_KEY_HEADER_NAME,
|
|
26
|
-
AUTH_SESSIONS_FOLDER_NAME: () => AUTH_SESSIONS_FOLDER_NAME,
|
|
27
|
-
AUTH_SESSIONS_INSTANCES_FOLDER_NAME: () => AUTH_SESSIONS_INSTANCES_FOLDER_NAME,
|
|
28
|
-
AUTH_TOKEN_ENV_VAR_KEY: () => AUTH_TOKEN_ENV_VAR_KEY,
|
|
29
|
-
CLI_ENV_VAR_KEY: () => CLI_ENV_VAR_KEY,
|
|
30
|
-
EXTENSION_PATH_ENV_VAR_KEY: () => EXTENSION_PATH_ENV_VAR_KEY,
|
|
31
|
-
PROJECT_ID_ENV_VAR_KEY: () => PROJECT_ID_ENV_VAR_KEY,
|
|
32
|
-
WORKSPACE_ID_ENV_VAR_KEY: () => WORKSPACE_ID_ENV_VAR_KEY
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
33
5
|
});
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
47
|
-
0 && (module.exports = {
|
|
48
|
-
API_BASE_URL_ENV_VAR_KEY,
|
|
49
|
-
API_FOLDER_NAME,
|
|
50
|
-
API_KEY_ENV_VAR_KEY,
|
|
51
|
-
API_KEY_HEADER_NAME,
|
|
52
|
-
AUTH_SESSIONS_FOLDER_NAME,
|
|
53
|
-
AUTH_SESSIONS_INSTANCES_FOLDER_NAME,
|
|
54
|
-
AUTH_TOKEN_ENV_VAR_KEY,
|
|
55
|
-
CLI_ENV_VAR_KEY,
|
|
56
|
-
EXTENSION_PATH_ENV_VAR_KEY,
|
|
57
|
-
PROJECT_ID_ENV_VAR_KEY,
|
|
58
|
-
WORKSPACE_ID_ENV_VAR_KEY
|
|
59
|
-
});
|
|
60
|
-
//# sourceMappingURL=constants.js.map
|
|
6
|
+
exports.WORKSPACE_ID_ENV_VAR_KEY = exports.PROJECT_ID_ENV_VAR_KEY = exports.EXTENSION_PATH_ENV_VAR_KEY = exports.CLI_ENV_VAR_KEY = exports.AUTH_TOKEN_ENV_VAR_KEY = exports.AUTH_SESSIONS_INSTANCES_FOLDER_NAME = exports.AUTH_SESSIONS_FOLDER_NAME = exports.API_KEY_HEADER_NAME = exports.API_KEY_ENV_VAR_KEY = exports.API_FOLDER_NAME = exports.API_BASE_URL_ENV_VAR_KEY = void 0;
|
|
7
|
+
const API_FOLDER_NAME = exports.API_FOLDER_NAME = "api";
|
|
8
|
+
const AUTH_SESSIONS_FOLDER_NAME = exports.AUTH_SESSIONS_FOLDER_NAME = "auth-sessions";
|
|
9
|
+
const AUTH_SESSIONS_INSTANCES_FOLDER_NAME = exports.AUTH_SESSIONS_INSTANCES_FOLDER_NAME = "auth-sessions-instances";
|
|
10
|
+
const WORKSPACE_ID_ENV_VAR_KEY = exports.WORKSPACE_ID_ENV_VAR_KEY = "INTUNED_WORKSPACE_ID";
|
|
11
|
+
const EXTENSION_PATH_ENV_VAR_KEY = exports.EXTENSION_PATH_ENV_VAR_KEY = "INTUNED_EXTENSION_PATH";
|
|
12
|
+
const PROJECT_ID_ENV_VAR_KEY = exports.PROJECT_ID_ENV_VAR_KEY = "INTUNED_PROJECT_ID";
|
|
13
|
+
const API_KEY_ENV_VAR_KEY = exports.API_KEY_ENV_VAR_KEY = "INTUNED_API_KEY";
|
|
14
|
+
const AUTH_TOKEN_ENV_VAR_KEY = exports.AUTH_TOKEN_ENV_VAR_KEY = "INTUNED_AUTH_TOKEN";
|
|
15
|
+
const API_KEY_HEADER_NAME = exports.API_KEY_HEADER_NAME = "x-api-key";
|
|
16
|
+
const API_BASE_URL_ENV_VAR_KEY = exports.API_BASE_URL_ENV_VAR_KEY = "INTUNED_API_BASE_URL";
|
|
17
|
+
const CLI_ENV_VAR_KEY = exports.CLI_ENV_VAR_KEY = "INTUNED_CLI";
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import * as playwright from
|
|
2
|
-
import { RunApiStorageState } from
|
|
3
|
-
|
|
1
|
+
import type * as playwright from "playwright";
|
|
2
|
+
import type { RunApiStorageState } from "@intuned/runtime-interface";
|
|
4
3
|
interface StorageEntry {
|
|
5
4
|
name: string;
|
|
6
5
|
value: string;
|
|
@@ -13,12 +12,11 @@ interface SessionStorageState {
|
|
|
13
12
|
origin: string;
|
|
14
13
|
sessionStorage: StorageEntry[];
|
|
15
14
|
}
|
|
16
|
-
interface StorageState {
|
|
15
|
+
export interface StorageState {
|
|
17
16
|
cookies?: playwright.Cookie[] | null;
|
|
18
17
|
origins?: LocalStorageState[] | null;
|
|
19
18
|
sessionStorage?: SessionStorageState[] | null;
|
|
20
19
|
}
|
|
21
|
-
declare function setStorageState(context: playwright.BrowserContext, state: RunApiStorageState): Promise<void>;
|
|
22
|
-
declare function getStorageState(context: playwright.BrowserContext): Promise<RunApiStorageState>;
|
|
23
|
-
|
|
24
|
-
export { type StorageState, getStorageState, setStorageState };
|
|
20
|
+
export declare function setStorageState(context: playwright.BrowserContext, state: RunApiStorageState): Promise<void>;
|
|
21
|
+
export declare function getStorageState(context: playwright.BrowserContext): Promise<RunApiStorageState>;
|
|
22
|
+
export {};
|
|
@@ -1,28 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __export = (target, all) => {
|
|
6
|
-
for (var name in all)
|
|
7
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
-
};
|
|
9
|
-
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
-
}
|
|
15
|
-
return to;
|
|
16
|
-
};
|
|
17
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
1
|
+
"use strict";
|
|
18
2
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
__export(contextStorageStateHelpers_exports, {
|
|
22
|
-
getStorageState: () => getStorageState,
|
|
23
|
-
setStorageState: () => setStorageState
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
24
5
|
});
|
|
25
|
-
|
|
6
|
+
exports.getStorageState = getStorageState;
|
|
7
|
+
exports.setStorageState = setStorageState;
|
|
26
8
|
async function setStorageState(context, state) {
|
|
27
9
|
if ("cookies" in state && state.cookies) {
|
|
28
10
|
await context.addCookies(state.cookies);
|
|
@@ -31,23 +13,17 @@ async function setStorageState(context, state) {
|
|
|
31
13
|
if ("origins" in state && state.origins) {
|
|
32
14
|
for (const originData of state.origins || []) {
|
|
33
15
|
const origin = originData.origin;
|
|
34
|
-
await page.route(
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
status: 200
|
|
40
|
-
})
|
|
41
|
-
);
|
|
16
|
+
await page.route(`${origin}/*`, route => route.fulfill({
|
|
17
|
+
body: "<html><head><title>Set Storage</title></head><body><h1>Set Storage</h1></body></html>",
|
|
18
|
+
contentType: "text/html",
|
|
19
|
+
status: 200
|
|
20
|
+
}));
|
|
42
21
|
try {
|
|
43
22
|
await page.goto(origin);
|
|
44
23
|
for (const item of originData.localStorage) {
|
|
45
|
-
await page.evaluate(
|
|
46
|
-
(
|
|
47
|
-
|
|
48
|
-
},
|
|
49
|
-
[item.name, item.value]
|
|
50
|
-
);
|
|
24
|
+
await page.evaluate(([key, value]) => {
|
|
25
|
+
window.localStorage.setItem(key, value);
|
|
26
|
+
}, [item.name, item.value]);
|
|
51
27
|
}
|
|
52
28
|
} finally {
|
|
53
29
|
await page.unroute(`${origin}/*`);
|
|
@@ -55,8 +31,11 @@ async function setStorageState(context, state) {
|
|
|
55
31
|
}
|
|
56
32
|
}
|
|
57
33
|
if ("sessionStorage" in state && state.sessionStorage) {
|
|
58
|
-
await context.addInitScript(
|
|
59
|
-
for (const {
|
|
34
|
+
await context.addInitScript(storage => {
|
|
35
|
+
for (const {
|
|
36
|
+
origin,
|
|
37
|
+
sessionStorage
|
|
38
|
+
} of storage) {
|
|
60
39
|
if (window.location.origin === origin) {
|
|
61
40
|
for (const item of sessionStorage) {
|
|
62
41
|
const value = window.sessionStorage.getItem(item.name);
|
|
@@ -84,7 +63,9 @@ async function getStorageState(context) {
|
|
|
84
63
|
if (page.isClosed()) continue;
|
|
85
64
|
try {
|
|
86
65
|
const sessionData = await page.evaluate(() => {
|
|
87
|
-
const items = {
|
|
66
|
+
const items = {
|
|
67
|
+
...window.sessionStorage
|
|
68
|
+
};
|
|
88
69
|
return {
|
|
89
70
|
origin: window.location.origin,
|
|
90
71
|
sessionStorage: Object.entries(items).map(([name, value]) => ({
|
|
@@ -100,10 +81,4 @@ async function getStorageState(context) {
|
|
|
100
81
|
}
|
|
101
82
|
result["sessionStorage"] = sessionDataList;
|
|
102
83
|
return result;
|
|
103
|
-
}
|
|
104
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
105
|
-
0 && (module.exports = {
|
|
106
|
-
getStorageState,
|
|
107
|
-
setStorageState
|
|
108
|
-
});
|
|
109
|
-
//# sourceMappingURL=contextStorageStateHelpers.js.map
|
|
84
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type * as playwright from "playwright";
|
|
2
|
+
import { CaptchaSolverSettings, CaptchaSolverSettingsWithRunContext } from "../settingsSchema";
|
|
3
|
+
export declare function resolveCaptchaSolverSettings(input?: unknown): Promise<CaptchaSolverSettings>;
|
|
4
|
+
export declare function isIntunedExtensionLoaded(): boolean;
|
|
5
|
+
export declare function buildExtensionsList(): string[];
|
|
6
|
+
export declare function getIntunedExtensionPath(): string;
|
|
7
|
+
export declare function isIntunedExtensionEnabled(): Promise<boolean>;
|
|
8
|
+
export declare function getIntunedExtensionWorker(context: playwright.BrowserContext): Promise<playwright.Worker | null>;
|
|
9
|
+
export declare function getIntunedExtensionSettings(captchaSolverSettings: CaptchaSolverSettings): Promise<CaptchaSolverSettingsWithRunContext>;
|
|
10
|
+
export declare function getIntunedCaptchaSolverSettings(): Promise<CaptchaSolverSettings>;
|
|
11
|
+
export declare function setupIntunedExtension(): Promise<void>;
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.buildExtensionsList = buildExtensionsList;
|
|
7
|
+
exports.getIntunedCaptchaSolverSettings = getIntunedCaptchaSolverSettings;
|
|
8
|
+
exports.getIntunedExtensionPath = getIntunedExtensionPath;
|
|
9
|
+
exports.getIntunedExtensionSettings = getIntunedExtensionSettings;
|
|
10
|
+
exports.getIntunedExtensionWorker = getIntunedExtensionWorker;
|
|
11
|
+
exports.isIntunedExtensionEnabled = isIntunedExtensionEnabled;
|
|
12
|
+
exports.isIntunedExtensionLoaded = isIntunedExtensionLoaded;
|
|
13
|
+
exports.resolveCaptchaSolverSettings = resolveCaptchaSolverSettings;
|
|
14
|
+
exports.setupIntunedExtension = setupIntunedExtension;
|
|
15
|
+
var _settings = require("../../commands/common/utils/settings");
|
|
16
|
+
var _settingsSchema = require("../settingsSchema");
|
|
17
|
+
var _constants = require("../constants");
|
|
18
|
+
var _jwtTokenManager = require("../jwtTokenManager");
|
|
19
|
+
var _path = _interopRequireDefault(require("path"));
|
|
20
|
+
var _promises = require("fs/promises");
|
|
21
|
+
var _intunedExtensionServer = require("./intunedExtensionServer");
|
|
22
|
+
var _portfinder = require("portfinder");
|
|
23
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
24
|
+
const INTUNED_WORKER = "intunedWorker.js";
|
|
25
|
+
const INTUNED_EXTENSION_SETTINGS_FILE_NAME = "intunedSettings.json";
|
|
26
|
+
const INTUNED_CAPTCHA_EXTENSION_PORT_ENV_VAR = "INTUNED_CAPTCHA_EXTENSION_PORT";
|
|
27
|
+
let captchaSolverSettings = null;
|
|
28
|
+
async function getIntunedCaptchaExtensionPort() {
|
|
29
|
+
if (process.env.INTUNED_CAPTCHA_EXTENSION_PORT) {
|
|
30
|
+
return parseInt(process.env.INTUNED_CAPTCHA_EXTENSION_PORT, 10);
|
|
31
|
+
}
|
|
32
|
+
return await (0, _portfinder.getPort)({});
|
|
33
|
+
}
|
|
34
|
+
async function resolveCaptchaSolverSettings(input) {
|
|
35
|
+
const parsed = _settingsSchema.captchaSolverSettingsSchema.parse(input || {});
|
|
36
|
+
if (!parsed.port) {
|
|
37
|
+
parsed.port = await getIntunedCaptchaExtensionPort();
|
|
38
|
+
}
|
|
39
|
+
return parsed;
|
|
40
|
+
}
|
|
41
|
+
function getIntunedCaptchaExtensionPortFromEnv() {
|
|
42
|
+
const raw = process.env[INTUNED_CAPTCHA_EXTENSION_PORT_ENV_VAR];
|
|
43
|
+
if (!raw) return null;
|
|
44
|
+
const parsed = Number(raw);
|
|
45
|
+
if (!Number.isFinite(parsed) || parsed <= 0 || parsed > 65535) {
|
|
46
|
+
throw new Error(`Invalid ${INTUNED_CAPTCHA_EXTENSION_PORT_ENV_VAR}: ${raw}`);
|
|
47
|
+
}
|
|
48
|
+
return parsed;
|
|
49
|
+
}
|
|
50
|
+
function isIntunedExtensionLoaded() {
|
|
51
|
+
return !!getIntunedExtensionPath();
|
|
52
|
+
}
|
|
53
|
+
function buildExtensionsList() {
|
|
54
|
+
const extensionsList = [];
|
|
55
|
+
if (isIntunedExtensionLoaded()) {
|
|
56
|
+
const intunedExtensionPath = getIntunedExtensionPath();
|
|
57
|
+
extensionsList.push(intunedExtensionPath);
|
|
58
|
+
}
|
|
59
|
+
return extensionsList;
|
|
60
|
+
}
|
|
61
|
+
function getIntunedExtensionPath() {
|
|
62
|
+
return process.env.INTUNED_EXTENSION_PATH;
|
|
63
|
+
}
|
|
64
|
+
async function isIntunedExtensionEnabled() {
|
|
65
|
+
const path = getIntunedExtensionPath();
|
|
66
|
+
if (!path) {
|
|
67
|
+
return false;
|
|
68
|
+
}
|
|
69
|
+
const captchaSolverSettings = await getIntunedCaptchaSolverSettings();
|
|
70
|
+
return captchaSolverSettings.enabled;
|
|
71
|
+
}
|
|
72
|
+
async function getIntunedExtensionWorker(context) {
|
|
73
|
+
if (!(await isIntunedExtensionEnabled())) {
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
76
|
+
let attemptCount = 0;
|
|
77
|
+
while (attemptCount < 4) {
|
|
78
|
+
const intunedServiceWorker = context.serviceWorkers().find(serviceWorker => serviceWorker.url().includes(INTUNED_WORKER));
|
|
79
|
+
if (intunedServiceWorker) {
|
|
80
|
+
return intunedServiceWorker;
|
|
81
|
+
}
|
|
82
|
+
try {
|
|
83
|
+
await context.waitForEvent("serviceworker", {
|
|
84
|
+
timeout: 3000
|
|
85
|
+
});
|
|
86
|
+
} catch (err) {
|
|
87
|
+
console.log(`Error accessing service workers (attempt ${attemptCount})`);
|
|
88
|
+
}
|
|
89
|
+
attemptCount++;
|
|
90
|
+
}
|
|
91
|
+
console.error("Failed to get intuned worker after 5 attmepts");
|
|
92
|
+
return null;
|
|
93
|
+
}
|
|
94
|
+
async function getIntunedExtensionSettings(captchaSolverSettings) {
|
|
95
|
+
const [domain, workspaceId, projectId] = [process.env.FUNCTIONS_DOMAIN, process.env[_constants.WORKSPACE_ID_ENV_VAR_KEY], process.env.INTUNED_INTEGRATION_ID ?? process.env[_constants.PROJECT_ID_ENV_VAR_KEY]];
|
|
96
|
+
if (!domain || !workspaceId || !projectId) {
|
|
97
|
+
const missingEnvVars = [domain && "FUNCTIONS_DOMAIN", workspaceId && _constants.WORKSPACE_ID_ENV_VAR_KEY, projectId && `INTUNED_INTEGRATION_ID OR ${_constants.PROJECT_ID_ENV_VAR_KEY}`];
|
|
98
|
+
throw new Error(`Missing required environment variables: ${missingEnvVars}`);
|
|
99
|
+
}
|
|
100
|
+
const authentication = (() => {
|
|
101
|
+
if (process.env.INTUNED_API_KEY) {
|
|
102
|
+
return {
|
|
103
|
+
type: "apiKey",
|
|
104
|
+
apiKey: process.env.INTUNED_API_KEY
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
if (process.env.INTUNED_BASIC_AUTH_USERNAME && process.env.INTUNED_BASIC_AUTH_PASSWORD) {
|
|
108
|
+
const credentials = `${process.env.INTUNED_BASIC_AUTH_USERNAME}:${process.env.INTUNED_BASIC_AUTH_PASSWORD}`;
|
|
109
|
+
const token = Buffer.from(credentials, "utf-8").toString("base64");
|
|
110
|
+
return {
|
|
111
|
+
type: "basic",
|
|
112
|
+
token
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
return {
|
|
116
|
+
type: "bearer",
|
|
117
|
+
token: _jwtTokenManager.backendFunctionsTokenManager.token
|
|
118
|
+
};
|
|
119
|
+
})();
|
|
120
|
+
const baseUrl = process.env.INTUNED_API_BASE_URL ?? domain;
|
|
121
|
+
return {
|
|
122
|
+
...captchaSolverSettings,
|
|
123
|
+
workspaceId,
|
|
124
|
+
projectId,
|
|
125
|
+
baseUrl,
|
|
126
|
+
authentication
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
async function getIntunedCaptchaSolverSettings() {
|
|
130
|
+
if (captchaSolverSettings) {
|
|
131
|
+
return captchaSolverSettings;
|
|
132
|
+
}
|
|
133
|
+
const settings = await (0, _settings.getSettings)();
|
|
134
|
+
captchaSolverSettings = await resolveCaptchaSolverSettings(settings.captchaSolver);
|
|
135
|
+
return captchaSolverSettings;
|
|
136
|
+
}
|
|
137
|
+
async function setupIntunedExtension() {
|
|
138
|
+
if (!(await isIntunedExtensionEnabled())) {
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
const intunedExtensionPath = getIntunedExtensionPath();
|
|
142
|
+
const intunedExtensionSettingsPath = _path.default.join(intunedExtensionPath, INTUNED_EXTENSION_SETTINGS_FILE_NAME);
|
|
143
|
+
const captchaSolverSettings = await getIntunedCaptchaSolverSettings();
|
|
144
|
+
await (0, _intunedExtensionServer.setupIntunedExtensionServer)(captchaSolverSettings);
|
|
145
|
+
const captchaSolverSettingsWithRunContext = await getIntunedExtensionSettings(captchaSolverSettings);
|
|
146
|
+
await (0, _promises.writeFile)(intunedExtensionSettingsPath, JSON.stringify(captchaSolverSettingsWithRunContext));
|
|
147
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type * as playwright from "playwright";
|
|
2
|
+
import { Captcha, CaptchaCallback, CaptchaStatus } from "./types";
|
|
3
|
+
import { CaptchaSolverSettings } from "../settingsSchema";
|
|
4
|
+
export declare class ExtensionServer {
|
|
5
|
+
private tabs;
|
|
6
|
+
private app;
|
|
7
|
+
constructor();
|
|
8
|
+
private getOrCreateTab;
|
|
9
|
+
handleUpsertCaptcha(captcha: Captcha): Promise<void>;
|
|
10
|
+
start({ port, host, }: {
|
|
11
|
+
port: number;
|
|
12
|
+
host?: string;
|
|
13
|
+
}): Promise<void>;
|
|
14
|
+
stop(): Promise<void>;
|
|
15
|
+
getCaptchas(page: playwright.Page, status?: CaptchaStatus): Promise<Captcha[]>;
|
|
16
|
+
subscribe(page: playwright.Page, handler: CaptchaCallback, status?: CaptchaStatus): Promise<void>;
|
|
17
|
+
unsubscribe(page: playwright.Page, handler: CaptchaCallback, status?: CaptchaStatus): Promise<void>;
|
|
18
|
+
removeTab(tabId: number): void;
|
|
19
|
+
getTabId(page: playwright.Page): Promise<number>;
|
|
20
|
+
}
|
|
21
|
+
export declare function getIntunedExtensionServer(): ExtensionServer;
|
|
22
|
+
export declare function setupIntunedExtensionServer(captchaSolverSettings?: CaptchaSolverSettings): Promise<void>;
|
|
23
|
+
export declare function cleanIntunedExtensionServer(): Promise<void>;
|
|
24
|
+
export declare function getTabId(page: playwright.Page): Promise<number>;
|