@intuned/runtime-dev 1.3.13-kv.1 → 1.3.14-ts-runtime-helpers-1

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 (38) hide show
  1. package/bin/intuned-get-headless-user-agent +4 -0
  2. package/dist/commands/get-headless-user-agent.d.ts +1 -0
  3. package/dist/commands/get-headless-user-agent.js +18 -0
  4. package/dist/commands/intuned-cli/commands/run_authsession.command.d.ts +6 -6
  5. package/dist/commands/intuned-cli/commands/types.d.ts +2 -2
  6. package/dist/commands/intuned-cli/controller/authSession.d.ts +6 -6
  7. package/dist/commands/intuned-cli/helpers/auth.d.ts +1 -1
  8. package/dist/commands/intuned-cli/helpers/errors.d.ts +1 -1
  9. package/dist/commands/intuned-cli/helpers/errors.js +2 -2
  10. package/dist/commands/intuned-cli/helpers/intunedJson.d.ts +8 -140
  11. package/dist/commands/intuned-cli/helpers/intunedJson.js +12 -79
  12. package/dist/common/binStartupScript.js +8 -5
  13. package/dist/common/constants.d.ts +2 -0
  14. package/dist/common/constants.js +4 -2
  15. package/dist/common/{extensionsHelpers.d.ts → extension/extensionsHelpers.d.ts} +1 -1
  16. package/dist/common/{extensionsHelpers.js → extension/extensionsHelpers.js} +62 -6
  17. package/dist/common/extension/intunedExtensionServer.d.ts +25 -0
  18. package/dist/common/extension/intunedExtensionServer.js +164 -0
  19. package/dist/common/extension/types.d.ts +21 -0
  20. package/dist/common/extension/types.js +5 -0
  21. package/dist/common/intunedJson.d.ts +229 -0
  22. package/dist/common/intunedJson.js +133 -0
  23. package/dist/common/launchBrowser.d.ts +6 -0
  24. package/dist/common/launchBrowser.js +42 -17
  25. package/dist/common/runApi/index.js +6 -0
  26. package/dist/common/runApi/types.d.ts +20 -20
  27. package/dist/common/settingsSchema.d.ts +15 -1
  28. package/dist/common/settingsSchema.js +1 -0
  29. package/dist/index.d.ts +1 -0
  30. package/dist/index.js +44 -1
  31. package/dist/runtime/captcha.d.ts +18 -0
  32. package/dist/runtime/captcha.js +190 -0
  33. package/dist/runtime/captcha.test.js +214 -0
  34. package/dist/runtime/index.d.ts +1 -0
  35. package/dist/runtime/index.js +43 -0
  36. package/dist/runtime/persistentStore.test.js +101 -0
  37. package/package.json +6 -3
  38. package/WebTemplate.zip +0 -0
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env node
2
+
3
+ require("../dist/common/binStartupScript.js");
4
+ require("../dist/commands/get-headless-user-agent.js");
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+
3
+ var _commander = require("commander");
4
+ var _dotenv = _interopRequireDefault(require("dotenv"));
5
+ var _launchBrowser = require("../common/launchBrowser");
6
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
7
+ _dotenv.default.config();
8
+ _commander.program.description("get headless user agent").action(async () => {
9
+ try {
10
+ console.log(await (0, _launchBrowser.getHeadlessUserAgent)({
11
+ executablePath: await (0, _launchBrowser.getBrowserExecutablePath)()
12
+ }));
13
+ } catch (error) {
14
+ console.error("Error getting headless user agent:", error);
15
+ process.exit(1);
16
+ }
17
+ });
18
+ _commander.program.parse(process.argv);
@@ -1,29 +1,29 @@
1
1
  import { Command } from "commander";
2
2
  export declare const baseRunAuthSessionCommandOptionsSchema: import("zod").ZodObject<{
3
3
  proxy: import("zod").ZodOptional<import("zod").ZodString>;
4
- headless: import("zod").ZodDefault<import("zod").ZodBoolean>;
4
+ trace: import("zod").ZodDefault<import("zod").ZodBoolean>;
5
5
  timeout: import("zod").ZodEffects<import("zod").ZodEffects<import("zod").ZodDefault<import("zod").ZodString>, import("ms").StringValue, string | undefined>, number, string | undefined>;
6
+ headless: import("zod").ZodDefault<import("zod").ZodBoolean>;
6
7
  keepBrowserOpen: import("zod").ZodDefault<import("zod").ZodBoolean>;
7
8
  cdpUrl: import("zod").ZodOptional<import("zod").ZodString>;
8
- trace: import("zod").ZodDefault<import("zod").ZodBoolean>;
9
9
  checkAttempts: import("zod").ZodDefault<import("zod").ZodNumber>;
10
10
  createAttempts: import("zod").ZodDefault<import("zod").ZodNumber>;
11
11
  }, "strip", import("zod").ZodTypeAny, {
12
- headless: boolean;
12
+ trace: boolean;
13
13
  timeout: number;
14
+ headless: boolean;
14
15
  keepBrowserOpen: boolean;
15
- trace: boolean;
16
16
  checkAttempts: number;
17
17
  createAttempts: number;
18
18
  proxy?: string | undefined;
19
19
  cdpUrl?: string | undefined;
20
20
  }, {
21
21
  proxy?: string | undefined;
22
- headless?: boolean | undefined;
22
+ trace?: boolean | undefined;
23
23
  timeout?: string | undefined;
24
+ headless?: boolean | undefined;
24
25
  keepBrowserOpen?: boolean | undefined;
25
26
  cdpUrl?: string | undefined;
26
- trace?: boolean | undefined;
27
27
  checkAttempts?: number | undefined;
28
28
  createAttempts?: number | undefined;
29
29
  }>;
@@ -17,10 +17,10 @@ export declare const baseCommandOptionsSchema: z.ZodObject<{
17
17
  keepBrowserOpen: z.ZodDefault<z.ZodBoolean>;
18
18
  cdpUrl: z.ZodOptional<z.ZodString>;
19
19
  }, "strip", z.ZodTypeAny, {
20
- headless: boolean;
20
+ trace: boolean;
21
21
  timeout: number;
22
+ headless: boolean;
22
23
  keepBrowserOpen: boolean;
23
- trace: boolean;
24
24
  proxy?: string | undefined;
25
25
  cdpUrl?: string | undefined;
26
26
  }, {
@@ -18,8 +18,8 @@ export declare function executeRunCreateAuthSessionCLI({ id, input, checkRetries
18
18
  cookies: {
19
19
  path: string;
20
20
  value: string;
21
- name: string;
22
21
  domain: string;
22
+ name: string;
23
23
  expires: number;
24
24
  httpOnly: boolean;
25
25
  secure: boolean;
@@ -49,8 +49,8 @@ export declare function executeRunUpdateAuthSessionCLI({ id, input, checkRetries
49
49
  cookies: {
50
50
  path: string;
51
51
  value: string;
52
- name: string;
53
52
  domain: string;
53
+ name: string;
54
54
  expires: number;
55
55
  httpOnly: boolean;
56
56
  secure: boolean;
@@ -78,8 +78,8 @@ export declare function executeAttemptCreateAuthSessionCLI({ id, input, ...rest
78
78
  cookies: {
79
79
  path: string;
80
80
  value: string;
81
- name: string;
82
81
  domain: string;
82
+ name: string;
83
83
  expires: number;
84
84
  httpOnly: boolean;
85
85
  secure: boolean;
@@ -106,8 +106,8 @@ export declare function executeAttemptCheckAuthSessionCLI({ id, ...rest }: {
106
106
  cookies: {
107
107
  path: string;
108
108
  value: string;
109
- name: string;
110
109
  domain: string;
110
+ name: string;
111
111
  expires: number;
112
112
  httpOnly: boolean;
113
113
  secure: boolean;
@@ -140,8 +140,8 @@ declare function runCreate({ authSessionInput, proxy, headless, timeout, traceId
140
140
  cookies: {
141
141
  path: string;
142
142
  value: string;
143
- name: string;
144
143
  domain: string;
144
+ name: string;
145
145
  expires: number;
146
146
  httpOnly: boolean;
147
147
  secure: boolean;
@@ -177,8 +177,8 @@ declare function runCreateWithRetries({ authSessionId, authSessionInput, retries
177
177
  cookies: {
178
178
  path: string;
179
179
  value: string;
180
- name: string;
181
180
  domain: string;
181
+ name: string;
182
182
  expires: number;
183
183
  httpOnly: boolean;
184
184
  secure: boolean;
@@ -8,8 +8,8 @@ export declare function loadAuthSessionInstance(authSessionId: string): Promise<
8
8
  cookies: {
9
9
  path: string;
10
10
  value: string;
11
- name: string;
12
11
  domain: string;
12
+ name: string;
13
13
  expires: number;
14
14
  httpOnly: boolean;
15
15
  secure: boolean;
@@ -1,4 +1,4 @@
1
- import { RunAutomationError } from "../../../common/runApi";
1
+ import { RunAutomationError } from "../../../common/runApi/errors";
2
2
  export declare class CLIError extends Error {
3
3
  autoColor: boolean;
4
4
  constructor(message: string, options?: {
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.CLIError = exports.CLIAssertionError = exports.AbortedCLIError = void 0;
7
7
  exports.logAutomationError = logAutomationError;
8
- var _runApi = require("../../../common/runApi");
8
+ var _errors = require("../../../common/runApi/errors");
9
9
  var _terminal = require("./terminal");
10
10
  class CLIError extends Error {
11
11
  constructor(message, options) {
@@ -31,7 +31,7 @@ class CLIAssertionError extends CLIError {
31
31
  exports.CLIAssertionError = CLIAssertionError;
32
32
  function logAutomationError(error) {
33
33
  (0, _terminal.terminal)(`^r^+An error occurred while running the API:^:\n`);
34
- if (error instanceof _runApi.AutomationError) {
34
+ if (error instanceof _errors.AutomationError) {
35
35
  if (error.error.stack) {
36
36
  const stackLines = error.error.stack.split("\n").filter(line => !line.includes("@intuned/runtime") && !line.includes("node:"));
37
37
  (0, _terminal.terminal)(`^r${stackLines.join("\n")}^:\n`);
@@ -1,139 +1,4 @@
1
- import { z } from "zod";
2
- export declare const intunedJsonSchema: z.ZodIntersection<z.ZodObject<{
3
- projectName: z.ZodOptional<z.ZodString>;
4
- workspaceId: z.ZodOptional<z.ZodString>;
5
- metadata: z.ZodCatch<z.ZodOptional<z.ZodObject<{
6
- defaultJobInput: z.ZodCatch<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>>;
7
- defaultRunPlaygroundInput: z.ZodCatch<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>>;
8
- testAuthSessionInput: z.ZodCatch<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>>;
9
- }, "strip", z.ZodTypeAny, {
10
- defaultJobInput?: Record<string, any> | undefined;
11
- defaultRunPlaygroundInput?: Record<string, any> | undefined;
12
- testAuthSessionInput?: Record<string, any> | undefined;
13
- }, {
14
- defaultJobInput?: unknown;
15
- defaultRunPlaygroundInput?: unknown;
16
- testAuthSessionInput?: unknown;
17
- }>>>;
18
- }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
19
- projectName: z.ZodOptional<z.ZodString>;
20
- workspaceId: z.ZodOptional<z.ZodString>;
21
- metadata: z.ZodCatch<z.ZodOptional<z.ZodObject<{
22
- defaultJobInput: z.ZodCatch<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>>;
23
- defaultRunPlaygroundInput: z.ZodCatch<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>>;
24
- testAuthSessionInput: z.ZodCatch<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>>;
25
- }, "strip", z.ZodTypeAny, {
26
- defaultJobInput?: Record<string, any> | undefined;
27
- defaultRunPlaygroundInput?: Record<string, any> | undefined;
28
- testAuthSessionInput?: Record<string, any> | undefined;
29
- }, {
30
- defaultJobInput?: unknown;
31
- defaultRunPlaygroundInput?: unknown;
32
- testAuthSessionInput?: unknown;
33
- }>>>;
34
- }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
35
- projectName: z.ZodOptional<z.ZodString>;
36
- workspaceId: z.ZodOptional<z.ZodString>;
37
- metadata: z.ZodCatch<z.ZodOptional<z.ZodObject<{
38
- defaultJobInput: z.ZodCatch<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>>;
39
- defaultRunPlaygroundInput: z.ZodCatch<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>>;
40
- testAuthSessionInput: z.ZodCatch<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>>;
41
- }, "strip", z.ZodTypeAny, {
42
- defaultJobInput?: Record<string, any> | undefined;
43
- defaultRunPlaygroundInput?: Record<string, any> | undefined;
44
- testAuthSessionInput?: Record<string, any> | undefined;
45
- }, {
46
- defaultJobInput?: unknown;
47
- defaultRunPlaygroundInput?: unknown;
48
- testAuthSessionInput?: unknown;
49
- }>>>;
50
- }, z.ZodTypeAny, "passthrough">>, z.ZodUnion<[z.ZodObject<{
51
- authSessions: z.ZodObject<{
52
- enabled: z.ZodLiteral<false>;
53
- }, "strip", z.ZodTypeAny, {
54
- enabled: false;
55
- }, {
56
- enabled: false;
57
- }>;
58
- apiAccess: z.ZodObject<{
59
- enabled: z.ZodLiteral<false>;
60
- }, "strip", z.ZodTypeAny, {
61
- enabled: false;
62
- }, {
63
- enabled: false;
64
- }>;
65
- }, "strip", z.ZodTypeAny, {
66
- authSessions: {
67
- enabled: false;
68
- };
69
- apiAccess: {
70
- enabled: false;
71
- };
72
- }, {
73
- authSessions: {
74
- enabled: false;
75
- };
76
- apiAccess: {
77
- enabled: false;
78
- };
79
- }>, z.ZodObject<{
80
- authSessions: z.ZodUnion<[z.ZodObject<{
81
- enabled: z.ZodLiteral<false>;
82
- }, "strip", z.ZodTypeAny, {
83
- enabled: false;
84
- }, {
85
- enabled: false;
86
- }>, z.ZodObject<{
87
- enabled: z.ZodLiteral<true>;
88
- type: z.ZodEnum<["MANUAL", "API"]>;
89
- startUrl: z.ZodOptional<z.ZodString>;
90
- finishUrl: z.ZodOptional<z.ZodString>;
91
- }, "strip", z.ZodTypeAny, {
92
- type: "API" | "MANUAL";
93
- enabled: true;
94
- startUrl?: string | undefined;
95
- finishUrl?: string | undefined;
96
- }, {
97
- type: "API" | "MANUAL";
98
- enabled: true;
99
- startUrl?: string | undefined;
100
- finishUrl?: string | undefined;
101
- }>]>;
102
- apiAccess: z.ZodObject<{
103
- enabled: z.ZodLiteral<true>;
104
- }, "strip", z.ZodTypeAny, {
105
- enabled: true;
106
- }, {
107
- enabled: true;
108
- }>;
109
- }, "strip", z.ZodTypeAny, {
110
- authSessions: {
111
- enabled: false;
112
- } | {
113
- type: "API" | "MANUAL";
114
- enabled: true;
115
- startUrl?: string | undefined;
116
- finishUrl?: string | undefined;
117
- };
118
- apiAccess: {
119
- enabled: true;
120
- };
121
- }, {
122
- authSessions: {
123
- enabled: false;
124
- } | {
125
- type: "API" | "MANUAL";
126
- enabled: true;
127
- startUrl?: string | undefined;
128
- finishUrl?: string | undefined;
129
- };
130
- apiAccess: {
131
- enabled: true;
132
- };
133
- }>]>>;
134
- export type IntunedJson = z.infer<typeof intunedJsonSchema>;
135
- export declare const intunedSettingsFileNames: readonly ["Intuned.json", "Intuned.jsonc", "Intuned.yaml", "Intuned.yml", "Intuned.toml"];
136
- export declare function loadIntunedJson(): Promise<{
1
+ export declare const loadIntunedJson: () => Promise<{
137
2
  projectName?: string | undefined;
138
3
  workspaceId?: string | undefined;
139
4
  metadata?: {
@@ -141,6 +6,9 @@ export declare function loadIntunedJson(): Promise<{
141
6
  defaultRunPlaygroundInput?: Record<string, any> | undefined;
142
7
  testAuthSessionInput?: Record<string, any> | undefined;
143
8
  } | undefined;
9
+ stealthMode?: {
10
+ enabled: boolean;
11
+ } | undefined;
144
12
  } & {
145
13
  [k: string]: unknown;
146
14
  } & ({
@@ -154,8 +22,8 @@ export declare function loadIntunedJson(): Promise<{
154
22
  authSessions: {
155
23
  enabled: false;
156
24
  } | {
157
- type: "API" | "MANUAL";
158
25
  enabled: true;
26
+ type: "API" | "MANUAL";
159
27
  startUrl?: string | undefined;
160
28
  finishUrl?: string | undefined;
161
29
  };
@@ -163,9 +31,9 @@ export declare function loadIntunedJson(): Promise<{
163
31
  enabled: true;
164
32
  };
165
33
  })>;
166
- export declare function getIntunedSettingsFile(): Promise<{
167
- name: typeof intunedSettingsFileNames[number];
34
+ export declare const getIntunedSettingsFile: () => Promise<{
35
+ name: "Intuned.json" | "Intuned.jsonc" | "Intuned.yaml" | "Intuned.yml" | "Intuned.toml";
168
36
  path: string;
169
37
  parse: (content: string) => any;
170
38
  }>;
171
- export declare function getIntunedSettingsFileName(): Promise<string>;
39
+ export declare const getIntunedSettingsFileName: () => Promise<"Intuned.json" | "Intuned.jsonc" | "Intuned.yaml" | "Intuned.yml" | "Intuned.toml">;
@@ -3,85 +3,18 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.getIntunedSettingsFile = getIntunedSettingsFile;
7
- exports.getIntunedSettingsFileName = getIntunedSettingsFileName;
8
- exports.intunedSettingsFileNames = exports.intunedJsonSchema = void 0;
9
- exports.loadIntunedJson = loadIntunedJson;
10
- var _path = _interopRequireDefault(require("path"));
11
- var fs = _interopRequireWildcard(require("fs-extra"));
12
- var _zod = require("zod");
6
+ exports.loadIntunedJson = exports.getIntunedSettingsFileName = exports.getIntunedSettingsFile = void 0;
13
7
  var _errors = require("./errors");
14
- var JSONC = _interopRequireWildcard(require("jsonc-parser"));
15
- var YAML = _interopRequireWildcard(require("yaml"));
16
- var TOML = _interopRequireWildcard(require("smol-toml"));
17
- 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); }
18
- 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; }
19
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
20
- const intunedJsonSchema = exports.intunedJsonSchema = _zod.z.object({
21
- projectName: _zod.z.string().optional(),
22
- workspaceId: _zod.z.string().optional(),
23
- metadata: _zod.z.object({
24
- defaultJobInput: _zod.z.record(_zod.z.any()).optional().catch(undefined),
25
- defaultRunPlaygroundInput: _zod.z.record(_zod.z.any()).optional().catch(undefined),
26
- testAuthSessionInput: _zod.z.record(_zod.z.any()).optional().catch(undefined)
27
- }).optional().catch(undefined)
28
- }).passthrough().and(_zod.z.union([_zod.z.object({
29
- authSessions: _zod.z.object({
30
- enabled: _zod.z.literal(false)
31
- }),
32
- apiAccess: _zod.z.object({
33
- enabled: _zod.z.literal(false)
34
- })
35
- }), _zod.z.object({
36
- authSessions: _zod.z.union([_zod.z.object({
37
- enabled: _zod.z.literal(false)
38
- }), _zod.z.object({
39
- enabled: _zod.z.literal(true),
40
- type: _zod.z.enum(["MANUAL", "API"]),
41
- startUrl: _zod.z.string().optional(),
42
- finishUrl: _zod.z.string().optional()
43
- })]),
44
- apiAccess: _zod.z.object({
45
- enabled: _zod.z.literal(true)
46
- })
47
- })]));
48
- const intunedSettingsFileNames = exports.intunedSettingsFileNames = ["Intuned.json", "Intuned.jsonc", "Intuned.yaml", "Intuned.yml", "Intuned.toml"];
49
- async function loadIntunedJson() {
50
- const settingsFile = await getIntunedSettingsFile();
51
- const intunedJsonContent = await fs.readFile(settingsFile.path, "utf-8");
52
- let intunedJson;
53
- try {
54
- intunedJson = settingsFile.parse(intunedJsonContent);
55
- } catch (e) {
56
- throw new _errors.CLIError(`Failed to parse ${settingsFile.name}: ${e.message}`);
57
- }
58
- const parseResult = intunedJsonSchema.safeParse(intunedJson);
59
- if (!parseResult.success) {
60
- const formattedError = parseResult.error.errors.map(e => `- ${e.path.join(".")}: ${e.message}`).join("\n");
61
- throw new _errors.CLIError(`${settingsFile.name} is not valid:\n${formattedError}\nPlease fix the errors and try again.`);
62
- }
63
- return parseResult.data;
64
- }
65
- const intunedSettingsParsers = {
66
- "Intuned.json": JSON.parse,
67
- "Intuned.jsonc": JSONC.parse,
68
- "Intuned.yaml": YAML.parse,
69
- "Intuned.yml": YAML.parse,
70
- "Intuned.toml": TOML.parse
71
- };
72
- async function getIntunedSettingsFile() {
73
- for (const fileName of intunedSettingsFileNames) {
74
- const filePath = _path.default.join(process.cwd(), fileName);
75
- if (await fs.exists(filePath)) {
76
- return {
77
- name: fileName,
78
- path: filePath,
79
- parse: intunedSettingsParsers[fileName]
80
- };
8
+ var _intunedJson = require("../../../common/intunedJson");
9
+ function unwrapped(fn) {
10
+ return async (...args) => {
11
+ const result = await fn(...args);
12
+ if (result.isErr()) {
13
+ throw new _errors.CLIError(result.error);
81
14
  }
82
- }
83
- throw new _errors.CLIError(`No Intuned settings file found.`);
15
+ return result.value;
16
+ };
84
17
  }
85
- async function getIntunedSettingsFileName() {
86
- return (await getIntunedSettingsFile()).name;
87
- }
18
+ const loadIntunedJson = exports.loadIntunedJson = unwrapped(_intunedJson.loadIntunedJson);
19
+ const getIntunedSettingsFile = exports.getIntunedSettingsFile = unwrapped(_intunedJson.getIntunedSettingsFile);
20
+ const getIntunedSettingsFileName = exports.getIntunedSettingsFileName = unwrapped(_intunedJson.getIntunedSettingsFileName);
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
 
3
3
  var _dotenv = _interopRequireDefault(require("dotenv"));
4
- var fs = _interopRequireWildcard(require("fs"));
5
4
  var path = _interopRequireWildcard(require("path"));
5
+ var _intunedJson = require("./intunedJson");
6
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
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
8
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
@@ -11,10 +11,13 @@ _dotenv.default.config({
11
11
  });
12
12
  function isStealthModeEnabled() {
13
13
  try {
14
- const intunedConfigPath = path.resolve(process.cwd(), process.env.ROOT || "./", "Intuned.json");
15
- const configContent = fs.readFileSync(intunedConfigPath, "utf8");
16
- const config = JSON.parse(configContent);
17
- return config.stealthMode?.enabled === true;
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;
18
21
  } catch (error) {
19
22
  console.error("Error reading Intuned.json:", error.message);
20
23
  return false;
@@ -8,3 +8,5 @@ export declare const API_KEY_ENV_VAR_KEY = "INTUNED_API_KEY";
8
8
  export declare const API_KEY_HEADER_NAME = "x-api-key";
9
9
  export declare const API_BASE_URL_ENV_VAR_KEY = "INTUNED_API_BASE_URL";
10
10
  export declare const CLI_ENV_VAR_KEY = "INTUNED_CLI";
11
+ export declare const INTUNED_AI_GATEWAY_BASE_URL_ENV_VAR = "INTUNED_AI_GATEWAY_BASE_URL";
12
+ export declare const INTUNED_AI_GATEWAY_API_KEY_ENV_VAR = "INTUNED_AI_GATEWAY_API_KEY";
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
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;
6
+ exports.WORKSPACE_ID_ENV_VAR_KEY = exports.PROJECT_ID_ENV_VAR_KEY = exports.INTUNED_AI_GATEWAY_BASE_URL_ENV_VAR = exports.INTUNED_AI_GATEWAY_API_KEY_ENV_VAR = 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
7
  const API_FOLDER_NAME = exports.API_FOLDER_NAME = "api";
8
8
  const AUTH_SESSIONS_FOLDER_NAME = exports.AUTH_SESSIONS_FOLDER_NAME = "auth-sessions";
9
9
  const AUTH_SESSIONS_INSTANCES_FOLDER_NAME = exports.AUTH_SESSIONS_INSTANCES_FOLDER_NAME = "auth-sessions-instances";
@@ -13,4 +13,6 @@ const PROJECT_ID_ENV_VAR_KEY = exports.PROJECT_ID_ENV_VAR_KEY = "INTUNED_PROJECT
13
13
  const API_KEY_ENV_VAR_KEY = exports.API_KEY_ENV_VAR_KEY = "INTUNED_API_KEY";
14
14
  const API_KEY_HEADER_NAME = exports.API_KEY_HEADER_NAME = "x-api-key";
15
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";
16
+ const CLI_ENV_VAR_KEY = exports.CLI_ENV_VAR_KEY = "INTUNED_CLI";
17
+ const INTUNED_AI_GATEWAY_BASE_URL_ENV_VAR = exports.INTUNED_AI_GATEWAY_BASE_URL_ENV_VAR = "INTUNED_AI_GATEWAY_BASE_URL";
18
+ const INTUNED_AI_GATEWAY_API_KEY_ENV_VAR = exports.INTUNED_AI_GATEWAY_API_KEY_ENV_VAR = "INTUNED_AI_GATEWAY_API_KEY";
@@ -1,5 +1,5 @@
1
1
  import * as playwright from "playwright";
2
- import { CaptchaSolverSettingsWithRunContext } from "./settingsSchema";
2
+ import { CaptchaSolverSettingsWithRunContext } from "../settingsSchema";
3
3
  export declare function buildExtensionsList(): string[];
4
4
  export declare function getIntunedExtensionPath(): string;
5
5
  export declare function isIntunedExtensionEnabled(): boolean;
@@ -9,15 +9,42 @@ exports.getIntunedExtensionSettings = getIntunedExtensionSettings;
9
9
  exports.getIntunedExtensionWorker = getIntunedExtensionWorker;
10
10
  exports.isIntunedExtensionEnabled = isIntunedExtensionEnabled;
11
11
  exports.setupIntunedExtension = setupIntunedExtension;
12
- var _settings = require("../commands/common/utils/settings");
13
- var _settingsSchema = require("./settingsSchema");
14
- var _constants = require("./constants");
15
- var _jwtTokenManager = require("./jwtTokenManager");
12
+ var _settings = require("../../commands/common/utils/settings");
13
+ var _settingsSchema = require("../settingsSchema");
14
+ var _constants = require("../constants");
15
+ var _jwtTokenManager = require("../jwtTokenManager");
16
16
  var _path = _interopRequireDefault(require("path"));
17
17
  var _promises = require("fs/promises");
18
+ var _intunedExtensionServer = require("./intunedExtensionServer");
19
+ var _nodeNet = _interopRequireDefault(require("node:net"));
18
20
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
19
21
  const INTUNED_WORKER = "intunedWorker.js";
20
22
  const INTUNED_EXTENSION_SETTINGS_FILE_NAME = "intunedSettings.json";
23
+ const INTUNED_CAPTCHA_EXTENSION_PORT_ENV_VAR = "INTUNED_CAPTCHA_EXTENSION_PORT";
24
+ function getIntunedCaptchaExtensionPortFromEnv() {
25
+ const raw = process.env[INTUNED_CAPTCHA_EXTENSION_PORT_ENV_VAR];
26
+ if (!raw) return null;
27
+ const parsed = Number(raw);
28
+ if (!Number.isFinite(parsed) || parsed <= 0 || parsed > 65535) {
29
+ throw new Error(`Invalid ${INTUNED_CAPTCHA_EXTENSION_PORT_ENV_VAR}: ${raw}`);
30
+ }
31
+ return parsed;
32
+ }
33
+ async function getFreeEphemeralPort() {
34
+ const server = _nodeNet.default.createServer();
35
+ server.unref();
36
+ await new Promise((resolve, reject) => {
37
+ server.once("error", reject);
38
+ server.listen(0, "127.0.0.1", () => resolve());
39
+ });
40
+ const address = server.address();
41
+ const port = typeof address === "object" && address && "port" in address ? address.port : null;
42
+ await new Promise(resolve => server.close(() => resolve()));
43
+ if (!port) {
44
+ throw new Error("Failed to allocate a free port for captcha extension");
45
+ }
46
+ return port;
47
+ }
21
48
  function buildExtensionsList() {
22
49
  const extensionsList = [];
23
50
  if (isIntunedExtensionEnabled()) {
@@ -61,12 +88,35 @@ async function getIntunedExtensionSettings() {
61
88
  const missingEnvVars = [domain && "FUNCTIONS_DOMAIN", workspaceId && _constants.WORKSPACE_ID_ENV_VAR_KEY, projectId && `INTUNED_INTEGRATION_ID OR ${_constants.PROJECT_ID_ENV_VAR_KEY}`];
62
89
  throw new Error(`Missing required environment variables: ${missingEnvVars}`);
63
90
  }
91
+ const authentication = (() => {
92
+ if (process.env.INTUNED_API_KEY) {
93
+ return {
94
+ type: "apiKey",
95
+ apiKey: process.env.INTUNED_API_KEY
96
+ };
97
+ }
98
+ if (process.env.INTUNED_BASIC_AUTH_USERNAME && process.env.INTUNED_BASIC_AUTH_PASSWORD) {
99
+ const credentials = `${process.env.INTUNED_BASIC_AUTH_USERNAME}:${process.env.INTUNED_BASIC_AUTH_PASSWORD}`;
100
+ const token = Buffer.from(credentials, "utf-8").toString("base64");
101
+ return {
102
+ type: "basic",
103
+ token
104
+ };
105
+ }
106
+ return {
107
+ type: "bearer",
108
+ token: _jwtTokenManager.backendFunctionsTokenManager.token
109
+ };
110
+ })();
111
+ const baseUrl = process.env.INTUNED_API_BASE_URL ?? domain;
112
+ const port = getIntunedCaptchaExtensionPortFromEnv() ?? (await getFreeEphemeralPort());
64
113
  return {
65
114
  ...(settings.captchaSolver ?? _settingsSchema.captchaSolverSettingsSchema.parse({})),
66
115
  workspaceId,
67
116
  projectId,
68
- baseUrl: domain,
69
- token: _jwtTokenManager.backendFunctionsTokenManager.token
117
+ baseUrl,
118
+ authentication,
119
+ port
70
120
  };
71
121
  }
72
122
  async function setupIntunedExtension() {
@@ -76,5 +126,11 @@ async function setupIntunedExtension() {
76
126
  const intunedExtensionPath = getIntunedExtensionPath();
77
127
  const intunedExtensionSettingsPath = _path.default.join(intunedExtensionPath, INTUNED_EXTENSION_SETTINGS_FILE_NAME);
78
128
  const settings = await getIntunedExtensionSettings();
129
+ if (!settings.enabled) {
130
+ return;
131
+ }
132
+ await (0, _intunedExtensionServer.setupIntunedExtensionServer)({
133
+ port: settings.port ?? 9000
134
+ });
79
135
  await (0, _promises.writeFile)(intunedExtensionSettingsPath, JSON.stringify(settings));
80
136
  }
@@ -0,0 +1,25 @@
1
+ import type * as playwright from "playwright";
2
+ import { Captcha, CaptchaCallback, CaptchaStatus } from "./types";
3
+ export declare class ExtensionServer {
4
+ private tabs;
5
+ private app;
6
+ isHealthy: boolean;
7
+ constructor();
8
+ private getOrCreateTab;
9
+ private handleUpsertCaptcha;
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
+ }
19
+ export declare function getIntunedExtensionServer(): ExtensionServer;
20
+ export declare function setupIntunedExtensionServer({ port, host, }: {
21
+ port: number;
22
+ host?: string;
23
+ }): Promise<void>;
24
+ export declare function cleanIntunedExtensionServer(): Promise<void>;
25
+ export declare function getTabId(page: playwright.Page): Promise<number>;