(value: string, url: string)
| 153 | } |
| 154 | }, [pastedCode, oauthStatus, showPastePrompt, urlCopied]); |
| 155 | async function handleSubmitCode(value: string, url: string) { |
| 156 | try { |
| 157 | // Expecting format "authorizationCode#state" from the authorization callback URL |
| 158 | const [authorizationCode, state] = value.split('#'); |
| 159 | if (!authorizationCode || !state) { |
| 160 | setOAuthStatus({ |
| 161 | state: 'error', |
| 162 | message: 'Invalid code. Please make sure the full code was copied', |
| 163 | toRetry: { |
| 164 | state: 'waiting_for_login', |
| 165 | url |
| 166 | } |
| 167 | }); |
| 168 | return; |
| 169 | } |
| 170 | |
| 171 | // Track which path the user is taking (manual code entry) |
| 172 | logEvent('tengu_oauth_manual_entry', {}); |
| 173 | oauthService.handleManualAuthCodeInput({ |
| 174 | authorizationCode, |
| 175 | state |
| 176 | }); |
| 177 | } catch (err: unknown) { |
| 178 | logError(err); |
| 179 | setOAuthStatus({ |
| 180 | state: 'error', |
| 181 | message: (err as Error).message, |
| 182 | toRetry: { |
| 183 | state: 'waiting_for_login', |
| 184 | url |
| 185 | } |
| 186 | }); |
| 187 | } |
| 188 | } |
| 189 | const startOAuth = useCallback(async () => { |
| 190 | try { |
| 191 | logEvent('tengu_oauth_flow_start', { |
no test coverage detected