fix(authFlows): persist PUZZLE/FACE step config in the flow builder#238
Merged
Conversation
The builder rendered the PUZZLE layer config (allowed challenge types, count,
difficulty, alsoMatchFaceIdentity) and the FACE active-puzzle-liveness toggle,
but the save path never serialized them into FlowStepSpec.config and the
edit-load path never parsed them back. A tenant's puzzle configuration was thus
silently dropped on save, and the runtime then rejected the step as unconfigured.
Add a pure, tested stepConfig module (serializeStepConfig/parseStepConfig) and
wire it into AuthFlowsPage handleSave (serialize) and getBuilderInitialSteps
(parse), so the config round-trips create -> get faithfully, matching the
backend AuthFlowPuzzleConfigRoundTripTest blob shape.
- serialize on save: PUZZLE -> puzzleConfig JSON; FACE -> {requireActivePuzzleLiveness}
- parse on edit-load: hydrate both back so re-save does not drop them
- 10 unit tests; tolerant of empty/malformed/absent config
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.
The auth-flow builder renders a PUZZLE layer config (allowed challenge types, count, difficulty,
alsoMatchFaceIdentity) and a FACE active-puzzle-liveness toggle, but:AuthFlowsPage.handleSave) never serialized them intoFlowStepSpec.config, andgetBuilderInitialSteps) never parsed them back.So a tenant who configured a puzzle layer had that configuration silently dropped on save, and the runtime then rejected the step as unconfigured. The capability already exists end-to-end at the data-model + API + runtime layers (backend
AuthFlowPuzzleConfigRoundTripTest); only the builder’s own save/load was unwired.Change
features/authFlows/stepConfig.ts:serializeStepConfig(step)→ PUZZLE:puzzleConfigJSON; FACE:{"requireActivePuzzleLiveness":true};undefinedfor ordinary steps (payload shape unchanged).parseStepConfig(config)→ hydrates both back; tolerant ofundefined/"{}"/ malformed (returns{}).AuthFlowsPagehandleSave(serialize) andgetBuilderInitialSteps(parse), so config round-trips create → get faithfully and survives editing.The serialized blob matches the backend round-trip-tested shape exactly:
{"allowedChallengeTypes":[...],"count":N,"difficulty":"medium","alsoMatchFaceIdentity":false}.Safety
app.auth.puzzle-layer(default OFF); FACE toggle is opt-in. Ordinary flows are byte-identical (config only emitted when present).Tests
stepConfig.test.ts(serialize, parse, round-trip, backend-parity, malformed input).authFlowssuite green (6 files / 48 tests);eslint+tsc --noEmitclean.