claude-browser-bridge 3.0.1 → 3.0.3

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 (2) hide show
  1. package/index.js +15 -9
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -17,14 +17,20 @@ import WebSocket, { WebSocketServer } from "ws";
17
17
 
18
18
  const PORT = Number(process.env.BRIDGE_PORT) || 8787;
19
19
 
20
- let TOKEN = null;
21
- try {
22
- TOKEN = readFileSync(new URL("./.bridge-token", import.meta.url), "utf8").trim();
23
- } catch {}
24
- if (!TOKEN) {
20
+ // F2 FIX: Re-read token on every auth attempt so `init` token regeneration
21
+ // takes effect without restarting the server.
22
+ const TOKEN_PATH = new URL("./.bridge-token", import.meta.url);
23
+ function readToken() {
24
+ try {
25
+ return readFileSync(TOKEN_PATH, "utf8").trim();
26
+ } catch {
27
+ return null;
28
+ }
29
+ }
30
+ if (!readToken()) {
25
31
  console.error(
26
- "[bridge] WARNING: server/.bridge-token is missing — run `node gen-token.js` " +
27
- "in the server directory. Refusing all extension connections until then."
32
+ "[bridge] WARNING: server/.bridge-token is missing — run `claude-browser-bridge init` " +
33
+ "or `node gen-token.js`. Refusing all extension connections until then."
28
34
  );
29
35
  }
30
36
 
@@ -87,7 +93,7 @@ function setupOwner(wss) {
87
93
  }
88
94
 
89
95
  if (!role) {
90
- if (msg.type === "auth" && TOKEN && msg.token === TOKEN) {
96
+ if (msg.type === "auth" && readToken() && msg.token === readToken()) {
91
97
  role = msg.role === "relay" ? "relay" : "extension";
92
98
  clearTimeout(authTimer);
93
99
  if (role === "extension") {
@@ -150,7 +156,7 @@ function connectRelay() {
150
156
  mode = "relay";
151
157
  const ws = new WebSocket(`ws://127.0.0.1:${PORT}`);
152
158
  ws.on("open", () => {
153
- ws.send(JSON.stringify({ type: "auth", token: TOKEN, role: "relay" }));
159
+ ws.send(JSON.stringify({ type: "auth", token: readToken(), role: "relay" }));
154
160
  upstream = ws;
155
161
  console.error(`[bridge] relay mode: forwarding through the session that owns port ${PORT}`);
156
162
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-browser-bridge",
3
- "version": "3.0.1",
3
+ "version": "3.0.3",
4
4
  "description": "Connect your live Chrome tabs to Claude Code — 57 tools for debugging, performance, accessibility, device emulation, and browser automation.",
5
5
  "type": "module",
6
6
  "bin": {