Repository navigation
Implement USER_SELECT, AUTH_FLOW_SELECT and USER_TYPE_SELECT inputs in the JavaScript core and React SDK - #106
Conversation
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configuration
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
🔀 Cross-SDK feature parity, ports raisedThis pull request is labelled Ports (DO NOT EDIT)
3 of 3 sibling SDKs accounted for. Every sibling SDK is accounted for. The contract is in the SDK development specification. |
|
ce68fb3 to
d1fb5c2
Compare
d1fb5c2 to
313e70e
Compare
313e70e to
65b9c06
Compare
Signed-off-by: Dilusha-Madushan <dilushamadushan9912@gmail.com> # Conflicts: # packages/javascript/src/index.ts # packages/javascript/src/utils/resolveResourceEndpoint.ts # Conflicts: # packages/node/src/ThunderIDNodeClient.ts # Conflicts: # packages/react/src/components/presentation/auth/AuthOptionFactory.tsx # packages/react/src/components/presentation/auth/__tests__/AuthOptionFactory.test.tsx # packages/vue/src/components/auth/sign-in/AuthOptionFactoryCore.ts
65b9c06 to
30d6ab0
Compare
Purpose
This PR adds three flow inputs for selecting users, authentication flows, and user types. Each picker loads options a page at a time as the user scrolls. It also adds masked text so a flow can hide a value, such as a client secret, until the user chooses to reveal it.
USER_SELECTAUTH_FLOW_SELECTUSER_TYPE_SELECTThunderID's agent onboarding flow uses
USER_SELECTto choose an owner and maskedCOPYABLE_TEXTto display the generated client secret. Copying a masked value still copies the original value.The built-in flow integration supports these pickers in
InviteUser, where a signed-in user's access token is available for the management API calls. Sign-in, sign-up, recovery, and accept-invite skip these inputs with a warning. They do not replace them with free-text fields.Approach
The implementation separates displaying options from loading them.
Selecthandles the dropdown and user interaction. The ReactuseInfiniteOptionshook and Vue composable manage loading and pagination.UserSelect,AuthFlowSelect, andUserTypeSelectconnect that shared behavior to their management APIs, withBasevariants for custom integrations.Selectaccepts ordinary options and an optionalonLoadMorecallback. When the end of the open list becomes visible, it requests more options. It avoids repeated requests for the same list length and does not request pages while closed or loading. A hidden input supports ordinary form submission, and the dropdown supports keyboard navigation and type-ahead.onErrorrather than displaying an inline error. Direct API errors are preserved, and server-backed integrations carry the status back to the browser.AbortSignaland report cancellation asABORT_ERROR.getFlowsandgetUserTypesoperations alongside the existing user API, with models and endpoint overrides. Node and Next.js exposegetUsers,getFlows, andgetUserTypesusing the session's access token. Express inherits the Node methods. React Router and TanStack Router inherit the React components without direct changes./api/auth/users,/api/auth/auth-flows, and/api/auth/user-types. These paths keep the access token on the server and return normalized options. Shared server-side validation checks paging values and limits user filters to 512 characters. Retry and failure logging happen on the server.InviteUsersupplies their loaders, validates required selections, and forwards loading failures to its existingonError. It also passes flow metadata and translations so templated headings resolve. The fetch hooks and composables are exported for apps composingBaseInviteUserthemselves.MaskedText, andCopyableTextuses it whenmaskedis true. Hidden values are omitted from the rendered DOM, and the placeholder does not reveal their length. An accessible Show/Hide button toggles visibility. The value remains available to the component for copying. The new picker and masking messages are included in all nine locales.This also fixes required
SELECTvalidation in React and Vue accept-invite flows, passesadditionalDatato Vue's invite and accept-invite factories for copyable values, and adds the missing React key to elements returned by custom flow renderers.Breaking changes
The React and Vue
Selectprimitives now render a custom dropdown instead of a native<select>. This allows the SDK to detect when the user reaches the end of the options and load another page. The closed control keeps its existing styling, and flowSELECTfields still submit the same value under the same reference.Apps that use native select behavior need to account for these changes:
multiple,size, andautoCompleteare ignored with a warning.selectOption()oruserEvent.selectOptions()must open the dropdown and click an option instead.<select>element must target the SDK's classes instead.onChangereceives an event-shaped object withtargetandcurrentTarget, rather than a real DOM event. ExistingChangeEvent<HTMLSelectElement>handler types remain supported, and handlers can continue readingevent.target.value.requiredattribute no longer provides browser form validation.Existing flow definitions do not need to change. Apps using
Selectdirectly should review their native attributes, event handling, CSS, and tests.Test coverage and validation
The added tests cover the behavior at each layer:
onChangehandlers. Layout-dependent component tests run in Chromium.The latest recorded local test results are listed below. These are package suite totals, not counts of tests added by this PR. They were checked against the implementation notes during this description update; the suites were not rerun for this documentation-only edit.
Related Issues
Related PRs
Checklist
breaking changelabel added.parity/prs-raisedorparity/prs-not-neededadded.parity/prs-raised, the port links are posted as a reply on the parity check's comment.Security checks