Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 1
feat(auth): --code bootstrap-code login for AI-paste onboarding#4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
bf5d9b5609120654a406786b8e15File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -90,13 +90,48 @@ export async function mapApiError(res: Response): Promise<CliError> { | ||
| return new PermissionError(cfg.activeWorkspaceSlug ?? '<unknown>'); | ||
| } | ||
| if (res.status === 409) return new ConflictError(msg, code ?? 'CONFLICT'); | ||
| // Phase 122 — bootstrap-code exchange error mapping. | ||
| // 404 and 410 collapse to the same user-facing message (oracle-attack | ||
| // defense — brute-force guessers can't distinguish "unknown code" from | ||
| // "already spent code"). ApiError.exitCode defaults to 1; we override | ||
| // to 5 on the instance so the CLI's exit-code contract stays honest | ||
| // ("API rejected the bootstrap code" is a distinct failure class). | ||
| if (res.status === 404 && code === 'BOOTSTRAP_NOT_FOUND') { | ||
| const err = new ApiError( | ||
| 'Code invalid or already used. Ask the dashboard user to click Copy again.', | ||
| 404, | ||
| ); | ||
| err.exitCode = 5; | ||
| return err; | ||
| } | ||
| if (res.status === 410 && code === 'BOOTSTRAP_EXPIRED_OR_USED') { | ||
| const err = new ApiError( | ||
| 'Code expired or already used. Ask the dashboard user to click Copy again.', | ||
| 410, | ||
| ); | ||
| err.exitCode = 5; | ||
| return err; | ||
| } | ||
Comment on lines
+99
to
+114
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unify 404/410 user-facing copy to preserve oracle-attack defense. Line 94-96 says these statuses should collapse to the same message, but Line 101 and Line 109 currently differ ( Proposed fix+ const bootstrapCodeRejectedMsg =+ 'Code invalid or already used. Ask the dashboard user to click Copy again.';+
if (res.status === 404 && code === 'BOOTSTRAP_NOT_FOUND') {
- const err = new ApiError(- 'Code invalid or already used. Ask the dashboard user to click Copy again.',- 404,- );+ const err = new ApiError(bootstrapCodeRejectedMsg, 404);
err.exitCode = 5;
return err;
}
if (res.status === 410 && code === 'BOOTSTRAP_EXPIRED_OR_USED') {
- const err = new ApiError(- 'Code expired or already used. Ask the dashboard user to click Copy again.',- 410,- );+ const err = new ApiError(bootstrapCodeRejectedMsg, 410);
err.exitCode = 5;
return err;
}🤖 Prompt for AI Agents | ||
| if (res.status === 429) { | ||
| // REUSE the existing ConflictError (exitCode 6) — output/error.ts has | ||
| // no dedicated rate-limit class, and inventing one here would fork the | ||
| // 7-code exit-code contract locked in Phase 108. The body.code | ||
| // 'RATE_LIMITED' matches the backend's UserIdThrottlerGuard structured | ||
| // 429 body. | ||
| return new ConflictError( | ||
| msg && msg !== 'Too Many Requests' | ||
| ? msg | ||
| : 'Too many codes minted. Wait a minute and retry.', | ||
| 'RATE_LIMITED', | ||
| ); | ||
| } | ||
| if (res.status >= 500) { | ||
| return new ApiError('Something went wrong on our end. Try again later.', res.status); | ||
| } | ||
| return new ApiError(msg, res.status); | ||
| } | ||
| function isNetworkFailure(err: unknown): boolean { | ||
| export function isNetworkFailure(err: unknown): boolean { | ||
| if (err instanceof TypeError) return true; | ||
| // eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
| const code = (err as any)?.code; | ||
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.