|
1 | 1 | /** |
2 | | - * Shared bridge auth/URL resolution. Consolidates the internal-only |
3 | | - * CLAUDE_BRIDGE_* dev overrides that were previously copy-pasted across |
4 | | - * a dozen files — inboundAttachments, BriefTool/upload, bridgeMain, |
5 | | - * initReplBridge, remoteBridgeCore, daemon workers, /rename, |
6 | | - * /remote-control. |
| 2 | + * Shared bridge auth/URL resolution. Consolidates the CLAUDE_BRIDGE_* |
| 3 | + * dev overrides that were previously copy-pasted across a dozen files — |
| 4 | + * inboundAttachments, BriefTool/upload, bridgeMain, initReplBridge, |
| 5 | + * remoteBridgeCore, daemon workers, /rename, /remote-control. |
7 | 6 | * |
8 | | - * Two layers: *Override() returns the internal-only env var (or undefined); |
| 7 | + * Two layers: *Override() returns the dev env var (or undefined); |
9 | 8 | * the non-Override versions fall through to the real OAuth store/config. |
10 | 9 | * Callers that compose with a different auth source (e.g. daemon workers |
11 | 10 | * using IPC auth) use the Override getters directly. |
|
14 | 13 | import { getOauthConfig } from '../constants/oauth.js' |
15 | 14 | import { getClaudeAIOAuthTokens } from '../utils/auth.js' |
16 | 15 |
|
17 | | -/** Ant-only dev override: CLAUDE_BRIDGE_OAUTH_TOKEN, else undefined. */ |
| 16 | +/** Dev override: CLAUDE_BRIDGE_OAUTH_TOKEN, else undefined. */ |
18 | 17 | export function getBridgeTokenOverride(): string | undefined { |
19 | | - return ( |
20 | | - (process.env.USER_TYPE === 'ant' && |
21 | | - process.env.CLAUDE_BRIDGE_OAUTH_TOKEN) || |
22 | | - undefined |
23 | | - ) |
| 18 | + return process.env.CLAUDE_BRIDGE_OAUTH_TOKEN || undefined |
24 | 19 | } |
25 | 20 |
|
26 | | -/** Ant-only dev override: CLAUDE_BRIDGE_BASE_URL, else undefined. */ |
| 21 | +/** Dev override: CLAUDE_BRIDGE_BASE_URL, else undefined. */ |
27 | 22 | export function getBridgeBaseUrlOverride(): string | undefined { |
28 | | - return ( |
29 | | - (process.env.USER_TYPE === 'ant' && process.env.CLAUDE_BRIDGE_BASE_URL) || |
30 | | - undefined |
31 | | - ) |
| 23 | + return process.env.CLAUDE_BRIDGE_BASE_URL || undefined |
32 | 24 | } |
33 | 25 |
|
34 | 26 | /** |
35 | | - * Access token for bridge API calls: dev override first, then the OAuth |
36 | | - * keychain. Undefined means "not logged in". |
| 27 | + * Access token for bridge API calls: env override first, then OAuth |
| 28 | + * keychain, then local bridge default token. |
37 | 29 | */ |
38 | 30 | export function getBridgeAccessToken(): string | undefined { |
39 | | - return getBridgeTokenOverride() ?? getClaudeAIOAuthTokens()?.accessToken |
| 31 | + return ( |
| 32 | + getBridgeTokenOverride() ?? |
| 33 | + getClaudeAIOAuthTokens()?.accessToken ?? |
| 34 | + 'openclaude-local-bridge' |
| 35 | + ) |
40 | 36 | } |
41 | 37 |
|
42 | 38 | /** |
43 | | - * Base URL for bridge API calls: dev override first, then the production |
44 | | - * OAuth config. Always returns a URL. |
| 39 | + * Base URL for bridge API calls: env override first, then OAuth config, |
| 40 | + * then localhost default for the local bridge server. |
45 | 41 | */ |
46 | 42 | export function getBridgeBaseUrl(): string { |
47 | | - return getBridgeBaseUrlOverride() ?? getOauthConfig().BASE_API_URL |
| 43 | + return ( |
| 44 | + getBridgeBaseUrlOverride() ?? |
| 45 | + getOauthConfig()?.BASE_API_URL ?? |
| 46 | + 'http://localhost:4080' |
| 47 | + ) |
48 | 48 | } |
0 commit comments