arn-browser 0.1.30 → 0.1.32

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.
@@ -17,7 +17,8 @@ import { FingerprintGenerator } from "fingerprint-generator";
17
17
 
18
18
  // Internal Utilities
19
19
  import { getMultiloginToken } from "../mlx_token.js";
20
- import { deleteDirectoryWithRetries } from "../deleteDirectory.js";
20
+ import { deleteDirectoryWithRetries } from "./deleteDirectory.js";
21
+ import { findBrowserPath } from "./findBrowserPath.js";
21
22
 
22
23
  // ==========================================================================
23
24
  // 1. CONFIGURATION & CONSTANTS
@@ -133,37 +134,8 @@ function resolveProfilePath(nameOrPath, browserName) {
133
134
  return path.join(PERSISTENT_DIR, folderName);
134
135
  }
135
136
 
136
- /**
137
- * Locates binaries for Chrome and Brave from the installed browsers.
138
- * Uses ~/.arn-browser/browsers/{browser}/{executable}
139
- */
140
- function getBinaryPath(browserName) {
141
- const isWindows = process.platform === "win32";
142
- const browsersDir = path.join(ARN_BROWSER_DIR, "browsers");
143
-
144
- const binaryMap = {
145
- brave: isWindows
146
- ? path.join(browsersDir, "brave", "brave.exe")
147
- : path.join(browsersDir, "brave", "brave"),
148
- chrome: isWindows
149
- ? path.join(browsersDir, "chromium", "chrome.exe")
150
- : path.join(browsersDir, "chromium", "chrome"),
151
- };
152
-
153
- const binaryPath = binaryMap[browserName];
154
- if (!binaryPath) {
155
- throw new Error(`░░░░░ [LaunchPuppeteer] Unknown browser: ${browserName}`);
156
- }
157
-
158
- if (!fs.existsSync(binaryPath)) {
159
- throw new Error(
160
- `░░░░░ [LaunchPuppeteer] ${browserName} binary not found at: ${binaryPath}\n` +
161
- ` Run "node bin/cli.js install" to install browsers.`
162
- );
163
- }
164
-
165
- return binaryPath;
166
- }
137
+ // Browser path resolution now uses OS-installed browsers via findBrowserPath.
138
+ // See src/utility/findBrowserPath.js for detection logic.
167
139
 
168
140
  /**
169
141
  * Writes or updates the profile metadata file.
@@ -315,6 +287,16 @@ export async function ppLaunch({
315
287
 
316
288
  switch (which_browser) {
317
289
  case "chrome":
290
+ result = await chromeLauncher({
291
+ profilePath: fullPath,
292
+ proxy,
293
+ timezoneId,
294
+ extraArgs,
295
+ spoof_fingerprint,
296
+ cleanupMinutes: effectiveCleanupMinutes,
297
+ browserType: "chrome",
298
+ });
299
+ break;
318
300
  case "chromium":
319
301
  result = await chromeLauncher({
320
302
  profilePath: fullPath,
@@ -323,6 +305,7 @@ export async function ppLaunch({
323
305
  extraArgs,
324
306
  spoof_fingerprint,
325
307
  cleanupMinutes: effectiveCleanupMinutes,
308
+ browserType: "chromium",
326
309
  });
327
310
  break;
328
311
  case "brave":
@@ -356,15 +339,15 @@ export async function ppLaunch({
356
339
  // 4. ENGINE: CHROME (CDP)
357
340
  // ==========================================================================
358
341
 
359
- async function chromeLauncher({ profilePath, proxy, timezoneId, extraArgs, spoof_fingerprint, cleanupMinutes }) {
342
+ async function chromeLauncher({ profilePath, proxy, timezoneId, extraArgs, spoof_fingerprint, cleanupMinutes, browserType = "chrome" }) {
360
343
  const isPersistent = !!profilePath;
361
344
  const activePath = isPersistent ? profilePath : path.join(TEMP_DIR, crypto.randomUUID());
362
345
 
363
346
  fs.mkdirSync(activePath, { recursive: true });
364
347
  writeProfileMeta(activePath, isPersistent ? "persistent" : "temp", cleanupMinutes);
365
- if (_launchLogs) console.log(`░░░░░ Starting Chrome [${isPersistent ? "Persistent" : "Temp"}]: ${activePath}`);
348
+ if (_launchLogs) console.log(`░░░░░ Starting ${browserType === "chromium" ? "Chromium" : "Chrome"} [${isPersistent ? "Persistent" : "Temp"}]: ${activePath}`);
366
349
 
367
- const binaryPath = getBinaryPath("chrome");
350
+ const binaryPath = findBrowserPath(browserType);
368
351
  return await spawnAndConnect({
369
352
  binaryPath,
370
353
  profilePath: activePath,
@@ -373,7 +356,7 @@ async function chromeLauncher({ profilePath, proxy, timezoneId, extraArgs, spoof
373
356
  timezoneId,
374
357
  extraArgs,
375
358
  spoof_fingerprint,
376
- browserLabel: "Chrome",
359
+ browserLabel: browserType === "chromium" ? "Chromium" : "Chrome",
377
360
  });
378
361
  }
379
362
 
@@ -439,7 +422,7 @@ async function braveLauncher({ profilePath, proxy, timezoneId, extraArgs, spoof_
439
422
  console.warn("░░░░░ Could not modify Brave Local State:", e.message);
440
423
  }
441
424
 
442
- const binaryPath = getBinaryPath("brave");
425
+ const binaryPath = findBrowserPath("brave");
443
426
  const braveArgs = [
444
427
  "--disable-features=Translate,BraveRewards,BraveWallet,BraveNews,Sidebar,SidePanel,BraveNTPBrandedWallpaper,NTPBackgroundImages",
445
428
  "--homepage=about:blank",
@@ -142,6 +142,9 @@ function sanitizeResponseHeaders(headers, logger, url) {
142
142
  }
143
143
  }
144
144
 
145
+ // Always ensure CORS header is present, even if server never sent it
146
+ cleaned["access-control-allow-origin"] = "*";
147
+
145
148
  if (logger && stripped.length) console.log(`[stripGot] Response stripped ${stripped.length} headers: [${stripped.join(", ")}] → ${url}`);
146
149
  return cleaned;
147
150
  }