@intuned/runtime 1.3.18 → 1.3.20

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.
@@ -1,7 +1,9 @@
1
1
  {
2
2
  "permissions": {
3
3
  "allow": [
4
- "Bash(npm info:*)"
4
+ "Bash(git -C /Users/yousefhanbali/Desktop/webapp/WebApp2 submodule status -- apps/web/packagerWorkerAssets/cookbook)",
5
+ "Bash(git -C /Users/yousefhanbali/Desktop/webapp/WebApp2 config --list --local)",
6
+ "Bash(git -C /Users/yousefhanbali/Desktop/webapp/WebApp2 config --get core.hooksPath)"
5
7
  ]
6
8
  }
7
9
  }
package/CHANGELOG.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # UNRELEASED
2
2
 
3
- -
3
+ - Add `timeout` parameter (in seconds, defaults to 30) to `launchBrowser` and `launchChromium` functions
4
4
 
5
5
  # 1.3.11
6
6
 
@@ -1,5 +1,6 @@
1
1
  export declare const loadIntunedJson: () => Promise<{
2
2
  stealthMode?: {
3
+ type: "intunedBrowser" | "patchright";
3
4
  enabled: boolean;
4
5
  } | undefined;
5
6
  workspaceId?: string | undefined;
@@ -22,7 +23,7 @@ export declare const loadIntunedJson: () => Promise<{
22
23
  authSessions: {
23
24
  enabled: false;
24
25
  } | {
25
- type: "API" | "MANUAL";
26
+ type: "MANUAL" | "API";
26
27
  enabled: true;
27
28
  startUrl?: string | undefined;
28
29
  finishUrl?: string | undefined;
@@ -8,22 +8,32 @@ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e
8
8
  _dotenv.default.config({
9
9
  path: `.env`
10
10
  });
11
- function isStealthModeEnabled() {
11
+ function getStealthModeConfig() {
12
12
  try {
13
13
  const settingsResult = (0, _intunedJson.loadIntunedJsonSync)();
14
14
  if (settingsResult.isErr()) {
15
15
  console.error(`Warning: Failed to load Intuned settings: ${settingsResult.error}
16
16
  Stealth mode will not be enabled.`);
17
- return false;
17
+ return {
18
+ enabled: false,
19
+ type: "patchright"
20
+ };
18
21
  }
19
- return settingsResult.value.stealthMode?.enabled === true;
22
+ return {
23
+ enabled: settingsResult.value.stealthMode?.enabled === true,
24
+ type: settingsResult.value.stealthMode?.type || "patchright"
25
+ };
20
26
  } catch (error) {
21
27
  console.error("Error reading Intuned.json:", error.message);
22
- return false;
28
+ return {
29
+ enabled: false,
30
+ type: "patchright"
31
+ };
23
32
  }
24
33
  }
25
34
  try {
26
- if (isStealthModeEnabled()) {
35
+ const stealthConfig = getStealthModeConfig();
36
+ if (stealthConfig.enabled && stealthConfig.type === "patchright") {
27
37
  const currentNodeModules = path.resolve(process.cwd(), "node_modules");
28
38
  process.env.NODE_PATH = process.env.NODE_PATH ? `${process.env.NODE_PATH}:${currentNodeModules}` : currentNodeModules;
29
39
  require("module").Module._initPaths();
@@ -58,9 +58,12 @@ async function getStorageState(context) {
58
58
  result.cookies = storageState.cookies;
59
59
  result.origins = storageState.origins;
60
60
  const sessionDataList = [];
61
- const pages = await context.pages();
61
+ const pages = context.pages();
62
62
  for (const page of pages) {
63
63
  if (page.isClosed()) continue;
64
+ if (page.url() === "about:blank" || page.url() === "chrome://newtab/" || page.url() === "edge://newtab/") {
65
+ continue;
66
+ }
64
67
  try {
65
68
  const sessionData = await page.evaluate(() => {
66
69
  const items = {
@@ -18,10 +18,13 @@ export declare const intunedJsonSchema: z.ZodIntersection<z.ZodObject<{
18
18
  }>>>;
19
19
  stealthMode: z.ZodCatch<z.ZodOptional<z.ZodObject<{
20
20
  enabled: z.ZodBoolean;
21
+ type: z.ZodDefault<z.ZodOptional<z.ZodEnum<["intunedBrowser", "patchright"]>>>;
21
22
  }, "strip", z.ZodTypeAny, {
23
+ type: "intunedBrowser" | "patchright";
22
24
  enabled: boolean;
23
25
  }, {
24
26
  enabled: boolean;
27
+ type?: "intunedBrowser" | "patchright" | undefined;
25
28
  }>>>;
26
29
  }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
27
30
  projectName: z.ZodOptional<z.ZodString>;
@@ -41,10 +44,13 @@ export declare const intunedJsonSchema: z.ZodIntersection<z.ZodObject<{
41
44
  }>>>;
42
45
  stealthMode: z.ZodCatch<z.ZodOptional<z.ZodObject<{
43
46
  enabled: z.ZodBoolean;
47
+ type: z.ZodDefault<z.ZodOptional<z.ZodEnum<["intunedBrowser", "patchright"]>>>;
44
48
  }, "strip", z.ZodTypeAny, {
49
+ type: "intunedBrowser" | "patchright";
45
50
  enabled: boolean;
46
51
  }, {
47
52
  enabled: boolean;
53
+ type?: "intunedBrowser" | "patchright" | undefined;
48
54
  }>>>;
49
55
  }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
50
56
  projectName: z.ZodOptional<z.ZodString>;
@@ -64,10 +70,13 @@ export declare const intunedJsonSchema: z.ZodIntersection<z.ZodObject<{
64
70
  }>>>;
65
71
  stealthMode: z.ZodCatch<z.ZodOptional<z.ZodObject<{
66
72
  enabled: z.ZodBoolean;
73
+ type: z.ZodDefault<z.ZodOptional<z.ZodEnum<["intunedBrowser", "patchright"]>>>;
67
74
  }, "strip", z.ZodTypeAny, {
75
+ type: "intunedBrowser" | "patchright";
68
76
  enabled: boolean;
69
77
  }, {
70
78
  enabled: boolean;
79
+ type?: "intunedBrowser" | "patchright" | undefined;
71
80
  }>>>;
72
81
  }, z.ZodTypeAny, "passthrough">>, z.ZodUnion<[z.ZodObject<{
73
82
  authSessions: z.ZodObject<{
@@ -111,12 +120,12 @@ export declare const intunedJsonSchema: z.ZodIntersection<z.ZodObject<{
111
120
  startUrl: z.ZodOptional<z.ZodString>;
112
121
  finishUrl: z.ZodOptional<z.ZodString>;
113
122
  }, "strip", z.ZodTypeAny, {
114
- type: "API" | "MANUAL";
123
+ type: "MANUAL" | "API";
115
124
  enabled: true;
116
125
  startUrl?: string | undefined;
117
126
  finishUrl?: string | undefined;
118
127
  }, {
119
- type: "API" | "MANUAL";
128
+ type: "MANUAL" | "API";
120
129
  enabled: true;
121
130
  startUrl?: string | undefined;
122
131
  finishUrl?: string | undefined;
@@ -132,7 +141,7 @@ export declare const intunedJsonSchema: z.ZodIntersection<z.ZodObject<{
132
141
  authSessions: {
133
142
  enabled: false;
134
143
  } | {
135
- type: "API" | "MANUAL";
144
+ type: "MANUAL" | "API";
136
145
  enabled: true;
137
146
  startUrl?: string | undefined;
138
147
  finishUrl?: string | undefined;
@@ -144,7 +153,7 @@ export declare const intunedJsonSchema: z.ZodIntersection<z.ZodObject<{
144
153
  authSessions: {
145
154
  enabled: false;
146
155
  } | {
147
- type: "API" | "MANUAL";
156
+ type: "MANUAL" | "API";
148
157
  enabled: true;
149
158
  startUrl?: string | undefined;
150
159
  finishUrl?: string | undefined;
@@ -157,6 +166,7 @@ export type IntunedJson = z.infer<typeof intunedJsonSchema>;
157
166
  export declare const intunedSettingsFileNames: readonly ["Intuned.json", "Intuned.jsonc", "Intuned.yaml", "Intuned.yml", "Intuned.toml"];
158
167
  export declare function loadIntunedJson(): Promise<Err<never, string> | Ok<{
159
168
  stealthMode?: {
169
+ type: "intunedBrowser" | "patchright";
160
170
  enabled: boolean;
161
171
  } | undefined;
162
172
  workspaceId?: string | undefined;
@@ -179,7 +189,7 @@ export declare function loadIntunedJson(): Promise<Err<never, string> | Ok<{
179
189
  authSessions: {
180
190
  enabled: false;
181
191
  } | {
182
- type: "API" | "MANUAL";
192
+ type: "MANUAL" | "API";
183
193
  enabled: true;
184
194
  startUrl?: string | undefined;
185
195
  finishUrl?: string | undefined;
@@ -196,6 +206,7 @@ export declare function getIntunedSettingsFile(): Promise<Ok<{
196
206
  export declare function getIntunedSettingsFileName(): Promise<Err<never, string> | Ok<"Intuned.json" | "Intuned.jsonc" | "Intuned.yaml" | "Intuned.yml" | "Intuned.toml", never>>;
197
207
  export declare function loadIntunedJsonSync(): Err<never, string> | Ok<{
198
208
  stealthMode?: {
209
+ type: "intunedBrowser" | "patchright";
199
210
  enabled: boolean;
200
211
  } | undefined;
201
212
  workspaceId?: string | undefined;
@@ -218,7 +229,7 @@ export declare function loadIntunedJsonSync(): Err<never, string> | Ok<{
218
229
  authSessions: {
219
230
  enabled: false;
220
231
  } | {
221
- type: "API" | "MANUAL";
232
+ type: "MANUAL" | "API";
222
233
  enabled: true;
223
234
  startUrl?: string | undefined;
224
235
  finishUrl?: string | undefined;
@@ -227,3 +238,7 @@ export declare function loadIntunedJsonSync(): Err<never, string> | Ok<{
227
238
  enabled: true;
228
239
  };
229
240
  }), never>;
241
+ export declare function getStealthModeConfig(): Promise<{
242
+ enabled: boolean;
243
+ type: "intunedBrowser" | "patchright";
244
+ }>;
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.getIntunedSettingsFile = getIntunedSettingsFile;
7
7
  exports.getIntunedSettingsFileName = getIntunedSettingsFileName;
8
+ exports.getStealthModeConfig = getStealthModeConfig;
8
9
  exports.intunedSettingsFileNames = exports.intunedJsonSchema = void 0;
9
10
  exports.loadIntunedJson = loadIntunedJson;
10
11
  exports.loadIntunedJsonSync = loadIntunedJsonSync;
@@ -28,7 +29,8 @@ const intunedJsonSchema = exports.intunedJsonSchema = _zod.z.object({
28
29
  testAuthSessionInput: _zod.z.record(_zod.z.any()).optional().catch(undefined)
29
30
  }).optional().catch(undefined),
30
31
  stealthMode: _zod.z.object({
31
- enabled: _zod.z.boolean()
32
+ enabled: _zod.z.boolean(),
33
+ type: _zod.z.enum(["intunedBrowser", "patchright"]).optional().default("patchright")
32
34
  }).optional().catch(undefined)
33
35
  }).passthrough().and(_zod.z.union([_zod.z.object({
34
36
  authSessions: _zod.z.object({
@@ -129,4 +131,24 @@ function getIntunedSettingsFileSync() {
129
131
  }
130
132
  }
131
133
  return (0, _neverthrow.err)("No Intuned settings file found.");
134
+ }
135
+ async function getStealthModeConfig() {
136
+ try {
137
+ const settingsResult = await loadIntunedJson();
138
+ if (settingsResult.isErr()) {
139
+ return {
140
+ enabled: false,
141
+ type: "patchright"
142
+ };
143
+ }
144
+ return {
145
+ enabled: settingsResult.value.stealthMode?.enabled === true,
146
+ type: settingsResult.value.stealthMode?.type || "patchright"
147
+ };
148
+ } catch {
149
+ return {
150
+ enabled: false,
151
+ type: "patchright"
152
+ };
153
+ }
132
154
  }
@@ -16,10 +16,12 @@ export type LaunchChromiumStandaloneOptions = {
16
16
  cdpPort?: number;
17
17
  appModeInitialUrl?: string;
18
18
  executablePath?: string;
19
+ timeout?: number;
19
20
  };
20
21
  export type LaunchChromiumCdpOptions = {
21
22
  cdpAddress: string;
22
23
  cdpTargetId?: string;
24
+ timeout?: number;
23
25
  };
24
26
  export declare function launchChromium(options: LaunchChromiumStandaloneOptions): Promise<LaunchBrowserResult>;
25
27
  export declare function launchChromium(options: LaunchChromiumCdpOptions): Promise<LaunchBrowserResult>;
@@ -20,6 +20,7 @@ var _intunedExtensionServer = require("./extension/intunedExtensionServer");
20
20
  var _util = require("util");
21
21
  var _neverthrow = require("neverthrow");
22
22
  var _zod = require("zod");
23
+ var _intunedJson = require("./intunedJson");
23
24
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
24
25
  function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
25
26
  const execAsync = (0, _util.promisify)(_child_process.exec);
@@ -65,6 +66,9 @@ async function launchChromium(options) {
65
66
  }
66
67
  }
67
68
  }
69
+ if (options.timeout !== undefined) {
70
+ context.setDefaultTimeout(options.timeout * 1000);
71
+ }
68
72
  return {
69
73
  page,
70
74
  context
@@ -75,13 +79,18 @@ async function launchChromium(options) {
75
79
  appModeInitialUrl,
76
80
  cdpPort,
77
81
  proxy,
78
- downloadsPath
82
+ downloadsPath,
83
+ timeout
79
84
  } = options;
80
85
  let {
81
86
  executablePath
82
87
  } = options;
83
88
  const defaultArgsToIgnore = ["--disable-extensions", "--disable-component-extensions-with-background-pages", "--disable-background-networking", "--disable-backgrounding-occluded-windows", "--disable-background-timer-throttling"];
84
89
  const extraArgs = [];
90
+ const stealthConfig = await (0, _intunedJson.getStealthModeConfig)();
91
+ if (stealthConfig.enabled && stealthConfig.type === "intunedBrowser") {
92
+ extraArgs.push("--stealth-mode");
93
+ }
85
94
  const userDataDir = await createUserDirWithPreferences();
86
95
  if ((0, _extensionsHelpers.isIntunedExtensionLoaded)()) {
87
96
  const extensionsList = (0, _extensionsHelpers.buildExtensionsList)();
@@ -105,7 +114,10 @@ async function launchChromium(options) {
105
114
  if (appModeInitialUrl) {
106
115
  extraArgs.push(`--app=${appModeInitialUrl}`);
107
116
  }
108
- if (executablePath) {
117
+ if (stealthConfig.enabled && stealthConfig.type === "intunedBrowser") {
118
+ const stealthExecutablePath = await getIntunedBrowserExecutablePath();
119
+ executablePath = stealthExecutablePath;
120
+ } else if (executablePath) {
109
121
  executablePath = await fs.realpath(executablePath);
110
122
  if (!(await fs.exists(executablePath))) {
111
123
  console.log(`Warning: Executable path ${executablePath} does not exist. Falling back to default.`);
@@ -126,6 +138,9 @@ async function launchChromium(options) {
126
138
  args: extraArgs,
127
139
  ignoreDefaultArgs: defaultArgsToIgnore
128
140
  });
141
+ if (timeout !== undefined) {
142
+ context.setDefaultTimeout(timeout * 1000);
143
+ }
129
144
  context.once("close", async () => {
130
145
  try {
131
146
  await (0, _fsExtra.rm)(userDataDir, {
@@ -154,6 +169,13 @@ async function launchChromium(options) {
154
169
  context
155
170
  };
156
171
  }
172
+ async function getIntunedBrowserExecutablePath() {
173
+ const intunedPath = process.env.INTUNED_BROWSER_PATH;
174
+ if (intunedPath && (await fs.exists(intunedPath))) {
175
+ return intunedPath;
176
+ }
177
+ return undefined;
178
+ }
157
179
  async function getBrowserExecutablePath() {
158
180
  const browserType = getBrowserType();
159
181
  if (browserType === "brave") {
@@ -260,7 +260,6 @@ var require_types = __commonJS({
260
260
  jobId: zod_1.default.string().optional(),
261
261
  jobRunId: zod_1.default.string().optional(),
262
262
  runId: zod_1.default.string().optional(),
263
- queueId: zod_1.default.string().optional(),
264
263
  authSessionId: zod_1.default.string().optional()
265
264
  }).optional()
266
265
  });
@@ -327,19 +326,29 @@ var require_interfaceClient = __commonJS({
327
326
  }) : function(o, v) {
328
327
  o["default"] = v;
329
328
  });
330
- var __importStar = exports2 && exports2.__importStar || function(mod) {
331
- if (mod && mod.__esModule) return mod;
332
- var result = {};
333
- if (mod != null) {
334
- for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
335
- }
336
- __setModuleDefault(result, mod);
337
- return result;
338
- };
329
+ var __importStar = exports2 && exports2.__importStar || /* @__PURE__ */ (function() {
330
+ var ownKeys = function(o) {
331
+ ownKeys = Object.getOwnPropertyNames || function(o2) {
332
+ var ar = [];
333
+ for (var k in o2) if (Object.prototype.hasOwnProperty.call(o2, k)) ar[ar.length] = k;
334
+ return ar;
335
+ };
336
+ return ownKeys(o);
337
+ };
338
+ return function(mod) {
339
+ if (mod && mod.__esModule) return mod;
340
+ var result = {};
341
+ if (mod != null) {
342
+ for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
343
+ }
344
+ __setModuleDefault(result, mod);
345
+ return result;
346
+ };
347
+ })();
339
348
  Object.defineProperty(exports2, "__esModule", { value: true });
340
349
  exports2.JSONLFileClient = exports2.TCPSocketClient = exports2.UnixSocketClient = exports2.SocketClient = void 0;
341
- var net = __importStar(require("net"));
342
350
  var fs = __importStar(require("fs-extra"));
351
+ var net = __importStar(require("net"));
343
352
  var readline_1 = require("readline");
344
353
  var promises_1 = require("timers/promises");
345
354
  var SocketClient = class _SocketClient {
@@ -376,6 +385,9 @@ var require_interfaceClient = __commonJS({
376
385
  break;
377
386
  }
378
387
  buffer = Buffer.concat([buffer, chunk]);
388
+ if (buffer.length < _SocketClient.LENGTH_HEADER_LENGTH) {
389
+ continue;
390
+ }
379
391
  const length = buffer.readUInt32BE(0);
380
392
  if (buffer.length < length + _SocketClient.LENGTH_HEADER_LENGTH) {
381
393
  continue;
package/package.json CHANGED
@@ -1,11 +1,10 @@
1
1
  {
2
2
  "name": "@intuned/runtime",
3
- "version": "1.3.18",
3
+ "version": "1.3.20",
4
4
  "description": "Intuned runtime",
5
5
  "packageManager": "yarn@4.12.0",
6
6
  "main": "./dist/index.js",
7
7
  "types": "./dist/index.d.ts",
8
- "private": false,
9
8
  "exports": {
10
9
  ".": "./dist/index.js",
11
10
  "./dist/runtime": "./dist/runtime/index.js",