claude-bridge-cli 1.5.1 → 2.0.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.
Files changed (2) hide show
  1. package/bin/cli.js +23 -15
  2. package/package.json +1 -1
package/bin/cli.js CHANGED
@@ -128,12 +128,11 @@ Options:
128
128
  Relay options (connect to a remote relay server):
129
129
  --relay-url <url> WebSocket URL of the relay server
130
130
  --machine <name> Machine name for the relay
131
- --token <bearer> Machine bearer (optional if omitted, the CLI starts
132
- a browser-OTP pair flow and caches the bearer at
133
- ~/.claude-bridge/auth.json for next time)
134
- --ephemeral Pair on every start, never read/write auth.json.
135
- Forces a fresh browser-OTP each launchuse on
136
- machines you don't want to leave any saved bearer on.
131
+ --token <bearer> Machine bearer (skips both auth.json and pair flow)
132
+ --save-auth Cache the bearer in ~/.claude-bridge/auth.json so the
133
+ next start reuses it. Required for unattended /
134
+ systemd-service installs. WITHOUT this flag the CLI
135
+ re-pairs (browser OTP) on every start the default.
137
136
  --cf-id <id> Cloudflare Access Client ID (optional)
138
137
  --cf-secret <secret> Cloudflare Access Client Secret (optional)
139
138
 
@@ -141,7 +140,9 @@ Environment variables:
141
140
  All options can be set via env vars with BRIDGE_ prefix:
142
141
  BRIDGE_PORT, BRIDGE_HOST, BRIDGE_CWD, BRIDGE_TIMEOUT,
143
142
  BRIDGE_RELAY_URL, BRIDGE_MACHINE_NAME, BRIDGE_MACHINE_TOKEN,
144
- BRIDGE_EPHEMERAL=1 (force fresh pair every start, no saved bearer),
143
+ BRIDGE_SAVE_AUTH=1 (cache the bearer to ~/.claude-bridge/auth.json
144
+ for unattended restarts; default re-pairs every
145
+ start so nothing is persisted),
145
146
  BRIDGE_CF_ID, BRIDGE_CF_SECRET
146
147
  `;
147
148
 
@@ -169,7 +170,8 @@ function main() {
169
170
  "relay-url": { type: "string", default: env("RELAY_URL", "") },
170
171
  machine: { type: "string", default: env("MACHINE_NAME", "") },
171
172
  token: { type: "string", default: env("MACHINE_TOKEN", "") },
172
- ephemeral: { type: "boolean", default: env("EPHEMERAL", "") === "1" },
173
+ "save-auth":{ type: "boolean", default: env("SAVE_AUTH", "") === "1" },
174
+ ephemeral: { type: "boolean", default: false }, // deprecated, now default behavior — kept as a no-op for compatibility
173
175
  "cf-id": { type: "string", default: env("CF_ID", "") },
174
176
  "cf-secret": { type: "string", default: env("CF_SECRET", "") },
175
177
  },
@@ -186,7 +188,10 @@ function main() {
186
188
  url: values["relay-url"],
187
189
  machine: values.machine,
188
190
  token: values.token,
189
- ephemeral: !!values.ephemeral,
191
+ // Default = ephemeral (pair on every start, never persist). Opt in
192
+ // to caching with --save-auth when running unattended / as a service.
193
+ // The legacy --ephemeral flag is a no-op (kept for back-compat).
194
+ saveAuth: !!values["save-auth"],
190
195
  cfId: values["cf-id"],
191
196
  cfSecret: values["cf-secret"],
192
197
  } : null,
@@ -250,19 +255,22 @@ async function run(config) {
250
255
  }
251
256
  // Resolve a bearer:
252
257
  // --token → use it directly (never look at auth.json)
253
- // --ephemeralalways pair fresh, never read or write auth.json
254
- // default saved auth.jsonfall back to pair flow on miss
258
+ // --save-authreuse saved auth.json; pair only if no entry exists
259
+ // default (no flags)pair fresh on every start, never read or write
260
+ // auth.json (most secure; requires user at the
261
+ // keyboard for every launch)
255
262
  if (!config.relay.token) {
256
- const saved = config.relay.ephemeral
257
- ? null
258
- : lookupSavedBearer(config.relay.url, config.relay.machine);
263
+ const saved = config.relay.saveAuth
264
+ ? lookupSavedBearer(config.relay.url, config.relay.machine)
265
+ : null;
259
266
  if (saved) {
260
267
  config.relay.token = saved;
261
268
  console.log(`[bridge] Using saved bearer from ${authFilePath()}`);
262
269
  } else {
263
270
  try {
271
+ // ephemeral == NOT saveAuth: don't write back when pair completes.
264
272
  config.relay.token = await pairInteractive(
265
- config.relay.url, config.relay.machine, config.relay.ephemeral
273
+ config.relay.url, config.relay.machine, /* ephemeral */ !config.relay.saveAuth
266
274
  );
267
275
  } catch (e) {
268
276
  console.error(`[bridge] ERROR: ${e.message}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-bridge-cli",
3
- "version": "1.5.1",
3
+ "version": "2.0.0",
4
4
  "description": "Use Claude Code from your browser. Runs a local server that connects your browser tools to the Claude CLI.",
5
5
  "main": "lib/bridge.js",
6
6
  "bin": {