@intuned/runtime-dev 1.3.17-source.0 → 1.3.18-interface.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (224) hide show
  1. package/InterfaceTemplate/index.playwright.ts +1 -1
  2. package/api/sample.ts +4 -0
  3. package/bin/intuned +0 -0
  4. package/bin/intuned-interface +7 -0
  5. package/package.json +10 -8
  6. package/dist/commands/api/run.d.ts +0 -6
  7. package/dist/commands/api/run.js +0 -119
  8. package/dist/commands/auth-sessions/load.d.ts +0 -2
  9. package/dist/commands/auth-sessions/load.js +0 -35
  10. package/dist/commands/auth-sessions/run-check.d.ts +0 -2
  11. package/dist/commands/auth-sessions/run-check.js +0 -74
  12. package/dist/commands/auth-sessions/run-create.d.ts +0 -2
  13. package/dist/commands/auth-sessions/run-create.js +0 -78
  14. package/dist/commands/browser/save-state.d.ts +0 -2
  15. package/dist/commands/browser/save-state.js +0 -17
  16. package/dist/commands/browser/start-browser.d.ts +0 -2
  17. package/dist/commands/browser/start-browser.js +0 -14
  18. package/dist/commands/build.d.ts +0 -1
  19. package/dist/commands/build.js +0 -85
  20. package/dist/commands/common/browserUtils.d.ts +0 -14
  21. package/dist/commands/common/browserUtils.js +0 -58
  22. package/dist/commands/common/getFirstLineNumber.d.ts +0 -9
  23. package/dist/commands/common/getFirstLineNumber.js +0 -101
  24. package/dist/commands/common/getFirstLineNumber.test.js +0 -228
  25. package/dist/commands/common/projectExclusions.d.ts +0 -2
  26. package/dist/commands/common/projectExclusions.js +0 -8
  27. package/dist/commands/common/sendMessageToClient.d.ts +0 -1
  28. package/dist/commands/common/sendMessageToClient.js +0 -10
  29. package/dist/commands/common/tsNodeImport.d.ts +0 -2
  30. package/dist/commands/common/tsNodeImport.js +0 -43
  31. package/dist/commands/common/utils/fileUtils.d.ts +0 -6
  32. package/dist/commands/common/utils/fileUtils.js +0 -33
  33. package/dist/commands/common/utils/settings.d.ts +0 -2
  34. package/dist/commands/common/utils/settings.js +0 -31
  35. package/dist/commands/common/utils/template.d.ts +0 -2
  36. package/dist/commands/common/utils/template.js +0 -31
  37. package/dist/commands/common/utils/unixSocket.d.ts +0 -23
  38. package/dist/commands/common/utils/unixSocket.js +0 -87
  39. package/dist/commands/get-headless-user-agent.d.ts +0 -1
  40. package/dist/commands/get-headless-user-agent.js +0 -18
  41. package/dist/commands/interface/run.d.ts +0 -1
  42. package/dist/commands/interface/run.js +0 -215
  43. package/dist/commands/intuned-cli/commands/attempt.command.d.ts +0 -1
  44. package/dist/commands/intuned-cli/commands/attempt.command.js +0 -8
  45. package/dist/commands/intuned-cli/commands/attempt_api.command.d.ts +0 -1
  46. package/dist/commands/intuned-cli/commands/attempt_api.command.js +0 -30
  47. package/dist/commands/intuned-cli/commands/attempt_authsession.command.d.ts +0 -1
  48. package/dist/commands/intuned-cli/commands/attempt_authsession.command.js +0 -8
  49. package/dist/commands/intuned-cli/commands/attempt_authsession_check.command.d.ts +0 -1
  50. package/dist/commands/intuned-cli/commands/attempt_authsession_check.command.js +0 -19
  51. package/dist/commands/intuned-cli/commands/attempt_authsession_create.command.d.ts +0 -1
  52. package/dist/commands/intuned-cli/commands/attempt_authsession_create.command.js +0 -24
  53. package/dist/commands/intuned-cli/commands/authsession.command.d.ts +0 -1
  54. package/dist/commands/intuned-cli/commands/authsession.command.js +0 -8
  55. package/dist/commands/intuned-cli/commands/authsession_record.command.d.ts +0 -1
  56. package/dist/commands/intuned-cli/commands/authsession_record.command.js +0 -32
  57. package/dist/commands/intuned-cli/commands/authsession_scaffold.command.d.ts +0 -1
  58. package/dist/commands/intuned-cli/commands/authsession_scaffold.command.js +0 -16
  59. package/dist/commands/intuned-cli/commands/build.command.d.ts +0 -1
  60. package/dist/commands/intuned-cli/commands/build.command.js +0 -12
  61. package/dist/commands/intuned-cli/commands/command.d.ts +0 -2
  62. package/dist/commands/intuned-cli/commands/command.js +0 -9
  63. package/dist/commands/intuned-cli/commands/deploy.command.d.ts +0 -1
  64. package/dist/commands/intuned-cli/commands/deploy.command.js +0 -42
  65. package/dist/commands/intuned-cli/commands/index.d.ts +0 -18
  66. package/dist/commands/intuned-cli/commands/index.js +0 -203
  67. package/dist/commands/intuned-cli/commands/provision.command.d.ts +0 -13
  68. package/dist/commands/intuned-cli/commands/provision.command.js +0 -50
  69. package/dist/commands/intuned-cli/commands/run.command.d.ts +0 -1
  70. package/dist/commands/intuned-cli/commands/run.command.js +0 -8
  71. package/dist/commands/intuned-cli/commands/run_api.command.d.ts +0 -1
  72. package/dist/commands/intuned-cli/commands/run_api.command.js +0 -46
  73. package/dist/commands/intuned-cli/commands/run_authsession.command.d.ts +0 -31
  74. package/dist/commands/intuned-cli/commands/run_authsession.command.js +0 -17
  75. package/dist/commands/intuned-cli/commands/run_authsession_create.command.d.ts +0 -1
  76. package/dist/commands/intuned-cli/commands/run_authsession_create.command.js +0 -35
  77. package/dist/commands/intuned-cli/commands/run_authsession_update.command.d.ts +0 -1
  78. package/dist/commands/intuned-cli/commands/run_authsession_update.command.js +0 -35
  79. package/dist/commands/intuned-cli/commands/run_authsession_validate.command.d.ts +0 -1
  80. package/dist/commands/intuned-cli/commands/run_authsession_validate.command.js +0 -33
  81. package/dist/commands/intuned-cli/commands/types.d.ts +0 -35
  82. package/dist/commands/intuned-cli/commands/types.js +0 -31
  83. package/dist/commands/intuned-cli/constants/index.d.ts +0 -17
  84. package/dist/commands/intuned-cli/constants/index.js +0 -25
  85. package/dist/commands/intuned-cli/controller/__test__/api.test.js +0 -398
  86. package/dist/commands/intuned-cli/controller/__test__/authSession.test.js +0 -1060
  87. package/dist/commands/intuned-cli/controller/api.d.ts +0 -42
  88. package/dist/commands/intuned-cli/controller/api.js +0 -194
  89. package/dist/commands/intuned-cli/controller/authSession.d.ts +0 -209
  90. package/dist/commands/intuned-cli/controller/authSession.js +0 -424
  91. package/dist/commands/intuned-cli/controller/build.d.ts +0 -1
  92. package/dist/commands/intuned-cli/controller/build.js +0 -36
  93. package/dist/commands/intuned-cli/controller/deploy.d.ts +0 -5
  94. package/dist/commands/intuned-cli/controller/deploy.js +0 -318
  95. package/dist/commands/intuned-cli/controller/index.d.ts +0 -1
  96. package/dist/commands/intuned-cli/controller/index.js +0 -46
  97. package/dist/commands/intuned-cli/controller/provision.d.ts +0 -21
  98. package/dist/commands/intuned-cli/controller/provision.js +0 -300
  99. package/dist/commands/intuned-cli/controller/scaffold.d.ts +0 -1
  100. package/dist/commands/intuned-cli/controller/scaffold.js +0 -77
  101. package/dist/commands/intuned-cli/helpers/__test__/browser.test.js +0 -115
  102. package/dist/commands/intuned-cli/helpers/__test__/tracing.test.js +0 -41
  103. package/dist/commands/intuned-cli/helpers/api.d.ts +0 -3
  104. package/dist/commands/intuned-cli/helpers/api.js +0 -16
  105. package/dist/commands/intuned-cli/helpers/auth.d.ts +0 -46
  106. package/dist/commands/intuned-cli/helpers/auth.js +0 -147
  107. package/dist/commands/intuned-cli/helpers/backend.d.ts +0 -8
  108. package/dist/commands/intuned-cli/helpers/backend.js +0 -35
  109. package/dist/commands/intuned-cli/helpers/browser.d.ts +0 -15
  110. package/dist/commands/intuned-cli/helpers/browser.js +0 -64
  111. package/dist/commands/intuned-cli/helpers/context.d.ts +0 -3
  112. package/dist/commands/intuned-cli/helpers/context.js +0 -33
  113. package/dist/commands/intuned-cli/helpers/errors.d.ts +0 -16
  114. package/dist/commands/intuned-cli/helpers/errors.js +0 -44
  115. package/dist/commands/intuned-cli/helpers/index.d.ts +0 -12
  116. package/dist/commands/intuned-cli/helpers/index.js +0 -137
  117. package/dist/commands/intuned-cli/helpers/intunedJson.d.ts +0 -39
  118. package/dist/commands/intuned-cli/helpers/intunedJson.js +0 -20
  119. package/dist/commands/intuned-cli/helpers/prompts.d.ts +0 -3
  120. package/dist/commands/intuned-cli/helpers/prompts.js +0 -71
  121. package/dist/commands/intuned-cli/helpers/proxy.d.ts +0 -5
  122. package/dist/commands/intuned-cli/helpers/proxy.js +0 -23
  123. package/dist/commands/intuned-cli/helpers/terminal.d.ts +0 -5
  124. package/dist/commands/intuned-cli/helpers/terminal.js +0 -13
  125. package/dist/commands/intuned-cli/helpers/timeout.d.ts +0 -1
  126. package/dist/commands/intuned-cli/helpers/timeout.js +0 -23
  127. package/dist/commands/intuned-cli/helpers/traces.d.ts +0 -2
  128. package/dist/commands/intuned-cli/helpers/traces.js +0 -32
  129. package/dist/commands/intuned-cli/helpers/validation.d.ts +0 -2
  130. package/dist/commands/intuned-cli/helpers/validation.js +0 -14
  131. package/dist/commands/intuned-cli/helpers/wrapper.d.ts +0 -2
  132. package/dist/commands/intuned-cli/helpers/wrapper.js +0 -76
  133. package/dist/commands/intuned-cli/index.d.ts +0 -1
  134. package/dist/commands/intuned-cli/index.js +0 -16
  135. package/dist/commands/intuned-cli/main.d.ts +0 -1
  136. package/dist/commands/intuned-cli/main.js +0 -36
  137. package/dist/commands/intuned-cli/types.d.ts +0 -70
  138. package/dist/commands/intuned-cli/types.js +0 -22
  139. package/dist/commands/ts-check.d.ts +0 -2
  140. package/dist/commands/ts-check.js +0 -56
  141. package/dist/common/Logger/Logger/index.d.ts +0 -12
  142. package/dist/common/Logger/Logger/index.js +0 -60
  143. package/dist/common/Logger/Logger/types.d.ts +0 -8
  144. package/dist/common/Logger/Logger/types.js +0 -5
  145. package/dist/common/Logger/index.d.ts +0 -12
  146. package/dist/common/Logger/index.js +0 -60
  147. package/dist/common/Logger/types.d.ts +0 -8
  148. package/dist/common/Logger/types.js +0 -5
  149. package/dist/common/assets/browser_scripts.js +0 -2580
  150. package/dist/common/asyncLocalStorage/index.d.ts +0 -16
  151. package/dist/common/asyncLocalStorage/index.js +0 -17
  152. package/dist/common/backendFunctions/getAuthSessionParameters.d.ts +0 -1
  153. package/dist/common/backendFunctions/getAuthSessionParameters.js +0 -38
  154. package/dist/common/binStartupScript.d.ts +0 -1
  155. package/dist/common/binStartupScript.js +0 -37
  156. package/dist/common/cleanEnvironmentVariables.d.ts +0 -1
  157. package/dist/common/cleanEnvironmentVariables.js +0 -16
  158. package/dist/common/constants.d.ts +0 -10
  159. package/dist/common/constants.js +0 -16
  160. package/dist/common/contextStorageStateHelpers.d.ts +0 -21
  161. package/dist/common/contextStorageStateHelpers.js +0 -81
  162. package/dist/common/extension/extensionsHelpers.d.ts +0 -11
  163. package/dist/common/extension/extensionsHelpers.js +0 -147
  164. package/dist/common/extension/intunedExtensionServer.d.ts +0 -24
  165. package/dist/common/extension/intunedExtensionServer.js +0 -178
  166. package/dist/common/extension/types.d.ts +0 -212
  167. package/dist/common/extension/types.js +0 -51
  168. package/dist/common/formatZodError.d.ts +0 -2
  169. package/dist/common/formatZodError.js +0 -18
  170. package/dist/common/intunedJson.d.ts +0 -229
  171. package/dist/common/intunedJson.js +0 -133
  172. package/dist/common/jwtTokenManager.d.ts +0 -17
  173. package/dist/common/jwtTokenManager.js +0 -109
  174. package/dist/common/launchBrowser.d.ts +0 -33
  175. package/dist/common/launchBrowser.js +0 -235
  176. package/dist/common/playwrightContext.d.ts +0 -31
  177. package/dist/common/playwrightContext.js +0 -150
  178. package/dist/common/runApi/errors.d.ts +0 -72
  179. package/dist/common/runApi/errors.js +0 -169
  180. package/dist/common/runApi/importUsingImportFunction.d.ts +0 -9
  181. package/dist/common/runApi/importUsingImportFunction.js +0 -46
  182. package/dist/common/runApi/index.d.ts +0 -11
  183. package/dist/common/runApi/index.js +0 -203
  184. package/dist/common/runApi/types.d.ts +0 -830
  185. package/dist/common/runApi/types.js +0 -73
  186. package/dist/common/settingsSchema.d.ts +0 -533
  187. package/dist/common/settingsSchema.js +0 -58
  188. package/dist/common/setupContextHook.d.ts +0 -17
  189. package/dist/common/setupContextHook.js +0 -22
  190. package/dist/common/telemetry.d.ts +0 -3
  191. package/dist/common/telemetry.js +0 -32
  192. package/dist/index.d.ts +0 -5
  193. package/dist/index.js +0 -124
  194. package/dist/runtime/RunError.d.ts +0 -5
  195. package/dist/runtime/RunError.js +0 -19
  196. package/dist/runtime/attemptStore.d.ts +0 -2
  197. package/dist/runtime/attemptStore.js +0 -23
  198. package/dist/runtime/captcha.d.ts +0 -15
  199. package/dist/runtime/captcha.js +0 -191
  200. package/dist/runtime/captcha.test.js +0 -821
  201. package/dist/runtime/downloadDirectory.d.ts +0 -1
  202. package/dist/runtime/downloadDirectory.js +0 -19
  203. package/dist/runtime/enums.d.js +0 -5
  204. package/dist/runtime/enums.d.ts +0 -11
  205. package/dist/runtime/enums.js +0 -18
  206. package/dist/runtime/executionHelpers.test.js +0 -52
  207. package/dist/runtime/export.d.js +0 -5
  208. package/dist/runtime/export.d.ts +0 -284
  209. package/dist/runtime/extendPayload.d.ts +0 -2
  210. package/dist/runtime/extendPayload.js +0 -21
  211. package/dist/runtime/extendTimeout.d.ts +0 -1
  212. package/dist/runtime/extendTimeout.js +0 -23
  213. package/dist/runtime/getAiGatewayConfig.d.ts +0 -10
  214. package/dist/runtime/getAiGatewayConfig.js +0 -16
  215. package/dist/runtime/getAuthSessionParameters.d.ts +0 -1
  216. package/dist/runtime/getAuthSessionParameters.js +0 -20
  217. package/dist/runtime/index.d.ts +0 -10
  218. package/dist/runtime/index.js +0 -111
  219. package/dist/runtime/persistentStore.d.ts +0 -2
  220. package/dist/runtime/persistentStore.js +0 -37
  221. package/dist/runtime/persistentStore.test.js +0 -101
  222. package/dist/runtime/runInfo.d.ts +0 -2
  223. package/dist/runtime/runInfo.js +0 -21
  224. /package/InterfaceTemplate/{utils.ts → __utils.ts} +0 -0
@@ -1,16 +0,0 @@
1
- /// <reference types="node" />
2
- import { AsyncLocalStorage } from "node:async_hooks";
3
- import { Payload, RunInfo } from "../../runtime/export";
4
- export declare const asyncLocalStorage: AsyncLocalStorage<InternalRunInfo>;
5
- export declare function runWithContext<R, TArgs extends any[]>(contextData: InternalRunInfo, callback: (...args: TArgs) => R, ...args: TArgs): R;
6
- interface TimeoutInfo {
7
- extendTimeoutCallback?: () => Promise<void>;
8
- }
9
- export interface InternalRunInfo extends RunInfo {
10
- extendedPayloads: Payload[];
11
- timeoutInfo?: TimeoutInfo;
12
- store?: Record<string, any>;
13
- getAuthSessionParameters?: () => Promise<any>;
14
- }
15
- export declare function getExecutionContext(): InternalRunInfo | undefined;
16
- export {};
@@ -1,17 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.asyncLocalStorage = void 0;
7
- exports.getExecutionContext = getExecutionContext;
8
- exports.runWithContext = runWithContext;
9
- var _nodeAsync_hooks = require("node:async_hooks");
10
- const asyncLocalStorage = exports.asyncLocalStorage = new _nodeAsync_hooks.AsyncLocalStorage();
11
- function runWithContext(contextData, callback, ...args) {
12
- return asyncLocalStorage.run(contextData, callback, ...args);
13
- }
14
- function getExecutionContext() {
15
- const contextData = asyncLocalStorage.getStore();
16
- return contextData;
17
- }
@@ -1 +0,0 @@
1
- export declare function getAuthSessionParameters(): Promise<any>;
@@ -1,38 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.getAuthSessionParameters = getAuthSessionParameters;
7
- var _isNil = _interopRequireDefault(require("lodash/isNil"));
8
- var _asyncLocalStorage = require("../asyncLocalStorage");
9
- var _zod = require("zod");
10
- var _jwtTokenManager = require("../jwtTokenManager");
11
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
12
- const authSessionParametersResponseSchema = _zod.z.object({
13
- parameters: _zod.z.any().refine(v => v !== undefined)
14
- });
15
- async function getAuthSessionParameters() {
16
- const context = (0, _asyncLocalStorage.getExecutionContext)();
17
- if (!context) {
18
- throw new Error("getAuthSessionParameters failed due to an internal error (context was not found).");
19
- }
20
- const authSessionId = context.authSessionId;
21
- if ((0, _isNil.default)(authSessionId)) {
22
- throw new Error("AuthSessions are not enabled");
23
- }
24
- const response = await (0, _jwtTokenManager.callBackendFunctionWithToken)(`auth-session/${authSessionId}/parameters`, {
25
- method: "GET"
26
- });
27
- const body = await response.text();
28
- if (!response.ok) {
29
- throw new Error(`getAuthSessionParameters failed with status ${response.status}: ${body}`);
30
- }
31
- let json;
32
- try {
33
- json = JSON.parse(body);
34
- } catch (e) {
35
- throw new Error(`Expected JSON response, but got ${body}`);
36
- }
37
- return authSessionParametersResponseSchema.parse(json).parameters;
38
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,37 +0,0 @@
1
- "use strict";
2
-
3
- var _dotenv = _interopRequireDefault(require("dotenv"));
4
- var path = _interopRequireWildcard(require("path"));
5
- var _intunedJson = require("./intunedJson");
6
- function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
7
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
8
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
9
- _dotenv.default.config({
10
- path: `.env`
11
- });
12
- function isStealthModeEnabled() {
13
- try {
14
- const settingsResult = (0, _intunedJson.loadIntunedJsonSync)();
15
- if (settingsResult.isErr()) {
16
- console.error(`Warning: Failed to load Intuned settings: ${settingsResult.error}
17
- Stealth mode will not be enabled.`);
18
- return false;
19
- }
20
- return settingsResult.value.stealthMode?.enabled === true;
21
- } catch (error) {
22
- console.error("Error reading Intuned.json:", error.message);
23
- return false;
24
- }
25
- }
26
- try {
27
- if (isStealthModeEnabled()) {
28
- const currentNodeModules = path.resolve(process.cwd(), "node_modules");
29
- process.env.NODE_PATH = process.env.NODE_PATH ? `${process.env.NODE_PATH}:${currentNodeModules}` : currentNodeModules;
30
- require("module").Module._initPaths();
31
- if (process.env.PLAYWRIGHT_PATCH_SCRIPT_PATH) {
32
- require(process.env.PLAYWRIGHT_PATCH_SCRIPT_PATH);
33
- }
34
- }
35
- } catch (e) {
36
- console.error("Failed to apply stealth mode");
37
- }
@@ -1 +0,0 @@
1
- export declare function cleanEnvironmentVariables(): void;
@@ -1,16 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.cleanEnvironmentVariables = cleanEnvironmentVariables;
7
- function cleanEnvironmentVariables() {
8
- Object.keys(process.env).filter(i => {
9
- if (i.toLocaleLowerCase().startsWith("npm")) {
10
- return true;
11
- }
12
- if (i.toLocaleLowerCase().startsWith("fly") && i !== "FLY_ALLOC_ID") {
13
- return true;
14
- }
15
- }).forEach(i => delete process.env[i]);
16
- }
@@ -1,10 +0,0 @@
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 API_KEY_HEADER_NAME = "x-api-key";
9
- export declare const API_BASE_URL_ENV_VAR_KEY = "INTUNED_API_BASE_URL";
10
- export declare const CLI_ENV_VAR_KEY = "INTUNED_CLI";
@@ -1,16 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
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_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 API_KEY_HEADER_NAME = exports.API_KEY_HEADER_NAME = "x-api-key";
15
- const API_BASE_URL_ENV_VAR_KEY = exports.API_BASE_URL_ENV_VAR_KEY = "INTUNED_API_BASE_URL";
16
- const CLI_ENV_VAR_KEY = exports.CLI_ENV_VAR_KEY = "INTUNED_CLI";
@@ -1,21 +0,0 @@
1
- import * as playwright from "playwright";
2
- interface StorageEntry {
3
- name: string;
4
- value: string;
5
- }
6
- interface LocalStorageState {
7
- origin: string;
8
- localStorage: StorageEntry[];
9
- }
10
- interface SessionStorageState {
11
- origin: string;
12
- sessionStorage: StorageEntry[];
13
- }
14
- export interface StorageState {
15
- cookies?: playwright.Cookie[] | null;
16
- origins?: LocalStorageState[] | null;
17
- sessionStorage?: SessionStorageState[] | null;
18
- }
19
- export declare function setStorageState(context: playwright.BrowserContext, state: StorageState): Promise<void>;
20
- export declare function getStorageState(context: playwright.BrowserContext): Promise<StorageState>;
21
- export {};
@@ -1,81 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.getStorageState = getStorageState;
7
- exports.setStorageState = setStorageState;
8
- async function setStorageState(context, state) {
9
- if ("cookies" in state && state.cookies) {
10
- await context.addCookies(state.cookies);
11
- }
12
- const page = await context.newPage();
13
- if ("origins" in state && state.origins) {
14
- for (const originData of state.origins || []) {
15
- const origin = originData.origin;
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
- }));
21
- try {
22
- await page.goto(origin);
23
- for (const item of originData.localStorage) {
24
- await page.evaluate(([key, value]) => {
25
- window.localStorage.setItem(key, value);
26
- }, [item.name, item.value]);
27
- }
28
- } finally {
29
- await page.unroute(`${origin}/*`);
30
- }
31
- }
32
- }
33
- if ("sessionStorage" in state && state.sessionStorage) {
34
- await context.addInitScript(storage => {
35
- for (const {
36
- origin,
37
- sessionStorage
38
- } of storage) {
39
- if (window.location.origin === origin) {
40
- for (const item of sessionStorage) {
41
- const value = window.sessionStorage.getItem(item.name);
42
- if (!value) {
43
- window.sessionStorage.setItem(item.name, item.value);
44
- }
45
- }
46
- }
47
- }
48
- }, state.sessionStorage);
49
- }
50
- await page.close();
51
- }
52
- async function getStorageState(context) {
53
- const result = {};
54
- const storageState = await context.storageState();
55
- result.cookies = storageState.cookies;
56
- result.origins = storageState.origins;
57
- const sessionDataList = [];
58
- const pages = await context.pages();
59
- for (const page of pages) {
60
- if (page.isClosed()) continue;
61
- try {
62
- const sessionData = await page.evaluate(() => {
63
- const items = {
64
- ...window.sessionStorage
65
- };
66
- return {
67
- origin: window.location.origin,
68
- sessionStorage: Object.entries(items).map(([name, value]) => ({
69
- name,
70
- value
71
- }))
72
- };
73
- });
74
- sessionDataList.push(sessionData);
75
- } catch (error) {
76
- console.error("Error getting sessionStorage:", error);
77
- }
78
- }
79
- result["sessionStorage"] = sessionDataList;
80
- return result;
81
- }
@@ -1,11 +0,0 @@
1
- import * 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>;
@@ -1,147 +0,0 @@
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
- }
@@ -1,24 +0,0 @@
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>;
@@ -1,178 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.ExtensionServer = void 0;
7
- exports.cleanIntunedExtensionServer = cleanIntunedExtensionServer;
8
- exports.getIntunedExtensionServer = getIntunedExtensionServer;
9
- exports.getTabId = getTabId;
10
- exports.setupIntunedExtensionServer = setupIntunedExtensionServer;
11
- var _fastify = _interopRequireDefault(require("fastify"));
12
- var _types = require("./types");
13
- var _extensionsHelpers = require("./extensionsHelpers");
14
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
15
- class TabCaptchaState {
16
- constructor(tabId) {
17
- this.tabId = tabId;
18
- this.captchasById = new Map();
19
- this.subscribers = new Array();
20
- }
21
- subscribe(handler) {
22
- this.subscribers.push(handler);
23
- }
24
- unsubscribe(handler, status) {
25
- const index = this.subscribers.findIndex(subscriber => subscriber.handler === handler && (subscriber.status === status || !status));
26
- if (index !== -1) {
27
- this.subscribers.splice(index, 1);
28
- }
29
- }
30
- getCaptchas() {
31
- return [...this.captchasById.values()];
32
- }
33
- async upsertCaptcha(captcha) {
34
- this.captchasById.set(captcha.id, captcha);
35
- for (const subscriber of this.subscribers) {
36
- if (!subscriber.status || subscriber.status === captcha.status) {
37
- await subscriber.handler(captcha);
38
- }
39
- }
40
- }
41
- }
42
- class ExtensionServer {
43
- app = null;
44
- constructor() {
45
- this.tabs = new Map();
46
- }
47
- getOrCreateTab(tabId) {
48
- const existing = this.tabs.get(tabId);
49
- if (existing) return existing;
50
- const created = new TabCaptchaState(tabId);
51
- this.tabs.set(tabId, created);
52
- return created;
53
- }
54
- async handleUpsertCaptcha(captcha) {
55
- const tab = this.getOrCreateTab(captcha.tabId);
56
- await tab.upsertCaptcha(captcha);
57
- }
58
- async start({
59
- port,
60
- host = "0.0.0.0"
61
- }) {
62
- if (this.app) {
63
- return;
64
- }
65
- this.app = (0, _fastify.default)({
66
- logger: false,
67
- bodyLimit: 1_000_000
68
- });
69
- this.app.post("/state", async (request, reply) => {
70
- try {
71
- const result = _types.captchaSchema.safeParse(request.body);
72
- if (!result.success) {
73
- return reply.code(400).send({
74
- error: "Invalid captcha payload",
75
- details: result.error.flatten().fieldErrors
76
- });
77
- }
78
- await this.handleUpsertCaptcha(result.data);
79
- return reply.code(200).send({});
80
- } catch (error) {
81
- console.error("Error processing captcha state update:", error);
82
- return reply.code(500).send({
83
- error: "Internal server error",
84
- message: error?.message ?? String(error)
85
- });
86
- }
87
- });
88
- this.app.setNotFoundHandler((_request, reply) => {
89
- return reply.code(404).send({
90
- error: "Not found"
91
- });
92
- });
93
- await this.app.listen({
94
- port,
95
- host
96
- });
97
- }
98
- async stop() {
99
- if (!this.app) return;
100
- const toClose = this.app;
101
- this.app = null;
102
- await toClose.close();
103
- }
104
- async getCaptchas(page, status) {
105
- const tabId = await getTabId(page);
106
- const tab = this.tabs.get(tabId);
107
- if (!tab) return [];
108
- const captchas = tab.getCaptchas();
109
- if (!status) return captchas;
110
- return captchas.filter(c => c.status === status && c.tabId === tabId);
111
- }
112
- async subscribe(page, handler, status) {
113
- const tabId = await getTabId(page);
114
- const tab = this.getOrCreateTab(tabId);
115
- tab.subscribe({
116
- handler,
117
- status
118
- });
119
- }
120
- async unsubscribe(page, handler, status) {
121
- const tabId = await getTabId(page);
122
- const tab = this.tabs.get(tabId);
123
- if (!tab) return;
124
- tab.unsubscribe(handler, status);
125
- }
126
- removeTab(tabId) {
127
- this.tabs.delete(tabId);
128
- }
129
- async getTabId(page) {
130
- return await getTabId(page);
131
- }
132
- }
133
- exports.ExtensionServer = ExtensionServer;
134
- let extensionServerSingleton = null;
135
- function getIntunedExtensionServer() {
136
- if (!extensionServerSingleton) {
137
- throw new Error("Intuned Extension Server is not initialized.");
138
- }
139
- return extensionServerSingleton;
140
- }
141
- async function setupIntunedExtensionServer(captchaSolverSettings) {
142
- if (!captchaSolverSettings) {
143
- captchaSolverSettings = await (0, _extensionsHelpers.resolveCaptchaSolverSettings)();
144
- }
145
- if (!extensionServerSingleton) {
146
- extensionServerSingleton = new ExtensionServer();
147
- }
148
- await extensionServerSingleton.start({
149
- port: captchaSolverSettings.port ?? 9000
150
- });
151
- }
152
- async function cleanIntunedExtensionServer() {
153
- if (extensionServerSingleton) {
154
- await extensionServerSingleton.stop();
155
- extensionServerSingleton = null;
156
- }
157
- }
158
- const TAB_ID_CACHE_KEY = "__INTUNED_CACHED_TAB_ID__";
159
- async function getTabId(page) {
160
- const cached = page[TAB_ID_CACHE_KEY];
161
- if (cached !== undefined && typeof cached === "number") {
162
- return cached;
163
- }
164
- let tabId;
165
- try {
166
- tabId = await page.evaluate("window.__INTUNED_TAB_ID__", {
167
- timeout: 100
168
- });
169
- } catch {
170
- await page.waitForFunction("window.__INTUNED_TAB_ID__ !== undefined", {
171
- timeout: 15_000
172
- });
173
- tabId = await page.evaluate("window.__INTUNED_TAB_ID__");
174
- }
175
- const numericTabId = Number(tabId);
176
- page[TAB_ID_CACHE_KEY] = numericTabId;
177
- return numericTabId;
178
- }