Implement USER_SELECT flow input in the JavaScript core and React SDK - #106
Dilusha-Madushan wants to merge 1 commit into
Conversation
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configurationConfiguration used: Repository: thunder-id/javascript-sdks/.coderabbit.yaml Review profile: CHILL Plan: Advanced Run ID:
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 parityDoes this change need to ship in the other ThunderID SDKs too? This check stays red until one of these labels answers that:
Ports (DO NOT EDIT)
3 of 3 sibling SDKs accounted for. The contract is in the SDK development specification. |
|
01071e7 to
c96864b
Compare
Signed-off-by: Dilusha-Madushan <dilushamadushan9912@gmail.com> # Conflicts: # packages/javascript/src/index.ts # packages/javascript/src/utils/resolveResourceEndpoint.ts
c96864b to
3f3994a
Compare
Purpose
Adds
USER_SELECT, a flow input that lets a step ask the user to pick one user from the directory and submits the chosen user's ID. Until now the SDK had no member for it inEmbeddedFlowComponentType, so a step that declared it could not be rendered by any SDK component.The picker is a paginated single-select: it loads nothing while closed, loads the first page on open, pages in more results on scroll or through a Load more button, and supports retry, keyboard navigation and screen readers. It is available in React, Vue, Next.js and Nuxt.
Loading users needs a signed-in user's access token with the
system:user:viewpermission, because the backend does not exposeGET /userson a public path. For that reasonUSER_SELECTis rendered only where a signed-in user exists (InviteUser). Sign-in, sign-up, recovery and accept-invite skip it with a warning, the same wayOU_SELECTis handled today, and never fall back to a free-text field. An application that needs a paginated picker with its own data source uses the genericPagedSelect.Approach
The feature is split into a generic paged-select layer and a thin user-specific wrapper, so a future
EMAIL_SELECTor any other paginated picker can reuse the paging and accessibility work.@thunderid/javascript): adds theUSER_SELECTenum member and the framework-neutral paged-select contract (PagedSelectOption,PagedSelectRequest,PagedSelectPage,FetchPagedOptions) with pure helpers for next-offset computation, de-duplication, option mapping and error mapping. User options are built from the existing management API: the picker reusesgetUsers,ManagedUser,ManagedUserListResponseand theendpoints.usersoverride rather than adding a second directory call. OnlyThunderIDErrormessages are shown to the user; any other failure falls back to a translatable generic message.@thunderid/browser):createHttpClientFetchernow forwards the caller'sAbortSignal, andFetchHttpClientreports an aborted request asABORT_ERRORinstead of a generic network error, so cancelling a superseded page request actually cancels it and is not shown as a failure.PagedSelectis the generic picker (public, takes afetchOptionsfunction) andUserSelectis a wrapper that builds the user-directory loader itself and takes no data source. In React the loader uses the same management endpoint resolution and authenticated fetcher as the other management hooks (the fetcher now forwards the request'sAbortSignal); in Vue it uses the SDK's authenticated HTTP client.BaseUserSelectis the building block that takes a loader, used byInviteUserthrough the component factory, in line with the otherBase*components. Stale results from a superseded request are dropped with a generation guard, and the panel keeps focus management and ARIA roles consistent with the existing popover components.InviteUsersupplies the loader and enforces a requiredUSER_SELECTlike any other required field. The pre-auth components are unchanged and skip the type with a warning.ThunderIDNodeClient.getUsersmakes one authenticated request on behalf of a session (Express inherits it). Next.js and Nuxt each provide aUserSelectthat loads through the server-held session, using a server action and aGET /api/auth/usersroute respectively. The browser sends onlylimit,offsetandfilter, never a session ID, token or URL, and receives only normalized{label, value}options, so the access token never reaches the client. Failures are returned as a plain result instead of thrown across the server-action boundary.PagedSelectis auto-registered in Nuxt.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