* Start auth flow by opening browser
(mainWindow: BrowserWindow | null)
| 207 | * Start auth flow by opening browser |
| 208 | */ |
| 209 | startAuthFlow(mainWindow: BrowserWindow | null): void { |
| 210 | const { shell } = require("electron") |
| 211 | |
| 212 | let authUrl = `${this.getApiUrl()}/auth/desktop?auto=true` |
| 213 | |
| 214 | // In dev mode, use localhost callback (we run HTTP server on AUTH_SERVER_PORT) |
| 215 | // Also pass the protocol so web knows which deep link to use as fallback |
| 216 | if (this.isDev) { |
| 217 | authUrl += `&callback=${encodeURIComponent(`http://localhost:${AUTH_SERVER_PORT}/auth/callback`)}` |
| 218 | // Pass dev protocol so production web can use correct deep link if callback fails |
| 219 | authUrl += `&protocol=twentyfirst-agents-dev` |
| 220 | } |
| 221 | |
| 222 | shell.openExternal(authUrl) |
| 223 | } |
| 224 | |
| 225 | /** |
| 226 | * Update user profile on server and locally |