-
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
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
bf5d9b5
feat(auth): add peekIdentity() for bootstrap-code was-diff
ord669 6091206
feat(auth): --code bootstrap-code login branch + error mapping
ord669 54a4067
fix(auth): gate 410 bootstrap-code mapping on BOOTSTRAP_EXPIRED_OR_USED
ord669 86b8e15
docs(auth): restore --workspace example in login help; add slug/name …
ord669 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; | ||
|
|
||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.