(value: string, url: string)
| 65 | } |
| 66 | } |
| 67 | async function handleSubmitCode(value: string, url: string) { |
| 68 | try { |
| 69 | // Expecting format "authorizationCode#state" from the authorization callback URL |
| 70 | const [authorizationCode, state] = value.split('#'); |
| 71 | if (!authorizationCode || !state) { |
| 72 | setOAuthStatus({ |
| 73 | state: 'error', |
| 74 | message: 'Invalid code. Please make sure the full code was copied', |
| 75 | toRetry: { |
| 76 | state: 'waiting_for_login', |
| 77 | url |
| 78 | } |
| 79 | }); |
| 80 | return; |
| 81 | } |
| 82 | |
| 83 | // Track which path the user is taking (manual code entry) |
| 84 | logEvent('tengu_oauth_manual_entry', {}); |
| 85 | oauthService.handleManualAuthCodeInput({ |
| 86 | authorizationCode, |
| 87 | state |
| 88 | }); |
| 89 | } catch (err: unknown) { |
| 90 | logError(err); |
| 91 | setOAuthStatus({ |
| 92 | state: 'error', |
| 93 | message: (err as Error).message, |
| 94 | toRetry: { |
| 95 | state: 'waiting_for_login', |
| 96 | url |
| 97 | } |
| 98 | }); |
| 99 | } |
| 100 | } |
| 101 | const startOAuth = useCallback(async () => { |
| 102 | // Clear any existing timers when starting new OAuth flow |
| 103 | timersRef.current.forEach(timer => clearTimeout(timer)); |
no test coverage detected