feat(accounts): hold and replay a request when the server asks for step-up - #22
Merged
Conversation
…ep-up Normalize the auth endpoint (a bare host gets /graphql, local hosts get http) and explain a 404 instead of surfacing it raw. On a typed STEP_UP_REQUIRED_* failure the request is held, the named factor is collected, verified through the SDK, and the identical request replayed once — no other failure retries.
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Two things that both came out of pointing dcrypt at a real auth plane: the endpoint field made you guess, and a step-up demand looked like a plain failure.
Endpoint.
normalizeEndpoint()runs before the SDK client is built, so what a human types becomes the URL the SDK needs:A 404 is then explained rather than surfaced raw —
no GraphQL endpoint at <url> — try <url>/graphql, or, when the URL already ends in/graphql, "check the host and that the auth plane is running".Step-up. The server raises typed exceptions (
STEP_UP_REQUIRED_PASSWORD/_MFA/_FRESH_AUTH); those become aStepUpRequiredErrorcarrying the factor, and nothing else does.AccountManagerholds the request rather than rebuilding it:With no proof the typed error propagates — that is what lets a UI collect one and call again.
createApiKey/revokeApiKeytake an optionalStepUpProof { password?, totpCode? }, which is transient: it is never written to the vault and never logged.The desktop screen keeps the failed closure itself, so the replay cannot pick up state that moved on while the dialog was open:
An IPC rejection reaches the renderer as a string, so
shared/step-up.tskeys off the server's own code rather than any wording of ours. The CLI gets the same behaviour:dcrypt account key create|revokeprompts for the named factor and re-runs the identical call.Tests cover the demand propagating when no proof is given, password and MFA each replaying once, a refused proof failing without a second attempt, and revoke keeping the local key until the server has accepted it.
Link to Devin session: https://app.devin.ai/sessions/04636534e07048089ffb6b78142e12cd
Requested by: @pyramation