IS-11495 Resolve WebAuthn attachment copy in the element component#261
Conversation
There was a problem hiding this comment.
Pull request overview
Refactors the HAAPI Stepper WebAuthn “any-device” registration attachment-selection UI so the element component resolves its own localized copy from the current step’s metadata.viewData.messages (via useHaapiStepper), rather than relying on step-data formatting to pre-shape WebAuthn-specific data onto actions.
Changes:
- Removes WebAuthn-specific
webauthnshaping fromformatNextStepDataand fromHaapiStepperClientOperationActiontyping. - Introduces
getWebAuthnRegistrationAttachmentalongside the WebAuthn card component and relocates tests accordingly. - Replaces a duplicate type guard with a generic
isAnyDeviceWebAuthnRegistrationClientOperation<T>that preserves the caller’s type on narrowing.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/haapi-react-sdk/haapi-stepper/feature/stepper/haapi-stepper.types.ts | Removes formatter-produced WebAuthn data from client-operation action typing. |
| src/haapi-react-sdk/haapi-stepper/feature/stepper/data-formatters/webauthn-data.spec.ts | Deletes resolver spec previously tied to the data-formatters layer. |
| src/haapi-react-sdk/haapi-stepper/feature/stepper/data-formatters/format-next-step-data.ts | Removes WebAuthn-specific enrichment while keeping WebAuthn action splitting. |
| src/haapi-react-sdk/haapi-stepper/feature/stepper/data-formatters/format-next-step-data.spec.ts | Deletes formatter-level assertions for WebAuthn enrichment that no longer exists. |
| src/haapi-react-sdk/haapi-stepper/feature/actions/client-operation/operations/webauthn/webauthn-registration-attachment.ts | Adds/moves resolver to the WebAuthn operations layer and returns the attachment model directly. |
| src/haapi-react-sdk/haapi-stepper/feature/actions/client-operation/operations/webauthn/webauthn-registration-attachment.spec.ts | Adds unit tests for the moved resolver. |
| src/haapi-react-sdk/haapi-stepper/feature/actions/client-operation/operations/webauthn/utils.ts | Updates the any-device WebAuthn registration type guard to be generic and type-preserving. |
| src/haapi-react-sdk/haapi-stepper/feature/actions/client-operation/operations/webauthn/HaapiStepperWebAuthnRegistrationAttachmentCard.tsx | Updates the card to resolve its copy via useHaapiStepper + resolver and changes props to accept the action. |
| src/haapi-react-sdk/haapi-stepper/feature/actions/client-operation/operations/webauthn/HaapiStepperWebAuthnRegistrationAttachmentCard.spec.tsx | Updates card tests to drive copy through a mocked useHaapiStepper. |
| src/haapi-react-sdk/haapi-stepper/feature/actions/client-operation/HaapiStepperClientOperationUI.tsx | Switches card rendering condition from action.webauthn to a WebAuthn any-device type guard. |
| src/haapi-react-sdk/haapi-stepper/feature/actions/client-operation/HaapiStepperClientOperationUI.spec.tsx | Updates client-operation UI tests to rely on mocked stepper messages instead of action-attached WebAuthn data. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
vahag-curity
left a comment
There was a problem hiding this comment.
👋 @aleixsuau — a review pass on this refactor, flagging a few things for you to weigh in on / handle if needed.
Verification: tsc --noEmit is clean, all 20 affected specs pass, the removed symbols leave no dangling references, and the default HAAPI stepper flow is not broken. So nothing here blocks the shipped path — the notes are about the API/altitude of moving copy resolution into the exported card.
Main theme (inline on HaapiStepperWebAuthnRegistrationAttachmentCard.tsx): resolving copy inside the exported presentational card via useHaapiStepper() couples it to the provider. That produces two effects — (1) the card now throws if reused standalone, which contradicts its own "reusable" doc comment (the same concern Copilot raised), and (2) a latent wrong-step-copy risk for consumers rendering non-current-step actions. Both are fixed by resolving at the HaapiStepperClientOperationUI call site (already inside the provider, already holding action + currentStep) and passing the attachment down as a prop.
Two more that aren't inline-able / are trivial:
- Barrel export —
operations/webauthn/index.tsre-exports every sibling helper except the moved./webauthn-registration-attachment, sogetAnyDeviceWebAuthnRegistrationAttachmentisn't on the public surface. Combined with the card no longer being standalone, consumers have no supported way to build the copy. Worth adding the export (or consciously keeping it internal). - Typo —
…AttachmentCard.spec.tsx:43: the test name should readstep'sbut uses a backtick instead of an apostrophe (already flagged by Copilot).
None are hard blockers — your call on how deep to go.
luisgoncalves
left a comment
There was a problem hiding this comment.
Skimmed on the changes and manually tested.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
e7f0b27 to
f3c006e
Compare
Jira: https://curity.atlassian.net/browse/IS-11495
Follow-up refactor to the WebAuthn attachment-selection cards (shipped in #254). It refactors the WebAuthn Any Device Registration attachment card to resolve its copy (kind / title / description) from the current step's
metadata.viewData.messages.