useStepUp
v0.64.0, changelogBetaRuns a sensitive action and, when the server answers with a step-up code, holds it, opens the step-up dialog, and replays it once the person is verified.
Replay
Install
npx shadcn add @syncrobotic/use-step-up Overview
When to use
- Every call the server may refuse with ELEVATED_SESSION_REQUIRED or TWO_FACTOR_SETUP_REQUIRED.
Use something else
- A confirmation with no identity check: Alert dialog.
Usage rules
- Wrap the call, not the click:
await. Any other error passes through untouched.stepUp.run(() => api.revokeKey(id)) - Catch
isStepUpCancelled(e)and say nothing happened; it is not a failure to report. - The codes are the server's contract (
codes,setupCodes); read them witherrorCodeOf, never from a message. - The replay runs once. If the server asks again, that error goes to the caller instead of a loop.
Changelog
- 0.64.02026-12-01Formatted with Prettier (class order sorted); the code is unchanged.
- 0.55.02026-11-27First release:
run(action), triggered byELEVATED_SESSION_REQUIREDandTWO_FACTOR_SETUP_REQUIRED(configurable), replays once afterverify; cancel rejects withStepUpCancelledError.errorCodeOfreadscodeor the envelope'serror.code, never the message.