browser-cookie-bridge 1.1.0 → 1.3.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.
package/src/config.js CHANGED
@@ -35,7 +35,7 @@ export function installConfig({ home, hour = 9, minute = 0, nodePath = process.e
35
35
  const sourceBrowser = SOURCE_BROWSERS.includes(existing.sourceBrowser) ? existing.sourceBrowser : "brave";
36
36
  const configuredTarget = TARGET_BROWSERS.includes(existing.targetBrowser) ? existing.targetBrowser : "codex";
37
37
  const config = {
38
- version: 1,
38
+ version: 2,
39
39
  token: existing.token || crypto.randomBytes(32).toString("base64url"),
40
40
  port: existing.port || DEFAULT_PORT,
41
41
  nodePath,
@@ -51,6 +51,11 @@ export function installConfig({ home, hour = 9, minute = 0, nodePath = process.e
51
51
  openAtLogin: existing.ui?.openAtLogin !== false,
52
52
  autoCheckUpdates: existing.ui?.autoCheckUpdates !== false,
53
53
  },
54
+ browserless: {
55
+ profileName: cleanProfileName(existing.browserless?.profileName) || "browser-cookie-bridge",
56
+ region: ["sfo", "lon", "ams"].includes(existing.browserless?.region) ? existing.browserless.region : "sfo",
57
+ onlyDomains: cleanDomains(existing.browserless?.onlyDomains),
58
+ },
54
59
  schedule: { hour, minute },
55
60
  createdAt: existing.createdAt || new Date().toISOString(),
56
61
  updatedAt: new Date().toISOString(),
@@ -63,7 +68,19 @@ export function installConfig({ home, hour = 9, minute = 0, nodePath = process.e
63
68
  return config;
64
69
  }
65
70
 
66
- export function updatePreferences({ home, cookies, history, sourceBrowser, targetBrowser, menuBar, openAtLogin, autoCheckUpdates }) {
71
+ export function updatePreferences({
72
+ home,
73
+ cookies,
74
+ history,
75
+ sourceBrowser,
76
+ targetBrowser,
77
+ menuBar,
78
+ openAtLogin,
79
+ autoCheckUpdates,
80
+ browserlessProfileName,
81
+ browserlessRegion,
82
+ browserlessOnlyDomains,
83
+ }) {
67
84
  const config = readConfig(home);
68
85
  if (!SOURCE_BROWSERS.includes(sourceBrowser)) {
69
86
  throw new Error(`Unsupported source browser: ${sourceBrowser}`);
@@ -82,6 +99,13 @@ export function updatePreferences({ home, cookies, history, sourceBrowser, targe
82
99
  openAtLogin: Boolean(openAtLogin),
83
100
  autoCheckUpdates: Boolean(autoCheckUpdates),
84
101
  };
102
+ const region = browserlessRegion ?? config.browserless?.region ?? "sfo";
103
+ if (!["sfo", "lon", "ams"].includes(region)) throw new Error("Browserless region must be sfo, lon, or ams");
104
+ config.browserless = {
105
+ profileName: cleanProfileName(browserlessProfileName ?? config.browserless?.profileName) || "browser-cookie-bridge",
106
+ region,
107
+ onlyDomains: cleanDomains(browserlessOnlyDomains ?? config.browserless?.onlyDomains),
108
+ };
85
109
  config.updatedAt = new Date().toISOString();
86
110
  writePrivateJson(configPath(home), config);
87
111
  return config;
@@ -92,10 +116,11 @@ export function installRuntime(home, source = projectRoot()) {
92
116
  if (path.resolve(source) === path.resolve(target)) return target;
93
117
 
94
118
  fs.mkdirSync(target, { recursive: true, mode: 0o700 });
95
- for (const name of ["bin", "src", "extension-template"]) {
119
+ for (const name of ["bin", "src", "extension-template", "node_modules"]) {
96
120
  fs.rmSync(path.join(target, name), { recursive: true, force: true });
97
121
  fs.cpSync(path.join(source, name), path.join(target, name), { recursive: true, force: true });
98
122
  }
123
+ fs.rmSync(path.join(target, "node_modules", ".bin"), { recursive: true, force: true });
99
124
  const appSource = path.join(source, "macos-app");
100
125
  const appTarget = path.join(target, "macos-app");
101
126
  fs.rmSync(appTarget, { recursive: true, force: true });
@@ -108,13 +133,22 @@ export function installRuntime(home, source = projectRoot()) {
108
133
  fs.copyFileSync(path.join(appSource, name), path.join(appTarget, name));
109
134
  }
110
135
  }
111
- for (const name of ["package.json", "README.md", "LICENSE"]) {
136
+ for (const name of ["package.json", "README.md", "LICENSE", "THIRD_PARTY_NOTICES.md"]) {
112
137
  fs.copyFileSync(path.join(source, name), path.join(target, name));
113
138
  }
114
139
  fs.chmodSync(path.join(target, "bin", "brave-codex-cookie-sync.js"), 0o700);
115
140
  return target;
116
141
  }
117
142
 
143
+ function cleanProfileName(value) {
144
+ return typeof value === "string" ? value.trim().slice(0, 100) : "";
145
+ }
146
+
147
+ function cleanDomains(value) {
148
+ const items = Array.isArray(value) ? value : typeof value === "string" ? value.split(",") : [];
149
+ return [...new Set(items.map((item) => String(item).trim().toLowerCase()).filter(Boolean))].slice(0, 50);
150
+ }
151
+
118
152
  function installExtension(config, home, browser, role) {
119
153
  const source = path.join(projectRoot(), "extension-template");
120
154
  const target = installedExtensionDir(home, browser);
package/src/paths.js CHANGED
@@ -10,7 +10,7 @@ export const DEFAULT_PORT = 43128;
10
10
  export const EXTENSION_ID = "ihanfnkcipmlhmokbcinlkdfcfheofjb";
11
11
  export const EXTENSION_ORIGIN = `chrome-extension://${EXTENSION_ID}`;
12
12
  export const SOURCE_BROWSERS = ["brave", "chrome", "edge", "arc", "vivaldi", "opera", "comet"];
13
- export const TARGET_BROWSERS = [...SOURCE_BROWSERS, "codex"];
13
+ export const TARGET_BROWSERS = [...SOURCE_BROWSERS, "codex", "browserless"];
14
14
 
15
15
  export function projectRoot() {
16
16
  return path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");