Repository navigation
fix: read SDK results as { data, error } across the guides and lint against regressions - #67
Merged
Merged
Conversation
PR #51 moved the react-sdk.mdx snippets to SeamlessAuthResult, but the page still introduced the pattern after first using it and did not say what the destructuring means. Add a Reading Results section next to the first headless-client example: what data and error hold, a short check-error-then-read-data example, and the two methods that do not return a result (isPasskeyPrfSupported, authorizedFetch). Other guides link back to it instead of repeating it. Also add the TOTP client methods and logoutAllSessions to the coverage list, make the finishOAuthLogin example check error before navigating, and replace the stale note that TOTP step-up is only on the raw routes with verifyStepUpWithTotp(code). The route list already matched authRoutePaths, so it is unchanged. Refs #10
The custom UI, OAuth, secure routes, and organizations guides still read
SDK results as a Response (response.ok, await response.json()) or as old
shapes (result.success, result.providers, status?.fresh). None of those
fields exist on SeamlessAuthResult, so the examples did not type-check
and branched on undefined at runtime.
The OAuth callback was a real bug: it wrapped finishOAuthLogin in a
try/catch, but the method never throws, so a failed callback still
navigated to the dashboard. It now surfaces error.message and returns.
Other changes:
- custom-auth-ui: login reads data.loginMethods, handlePasskeyLogin is
checked by error rather than as a boolean, and the passkey
registration section documents the real { credentialId, prfCapable }
payload. Registration no longer claims a phone is required.
- secure-routes: drop the issuer option, which SeamlessAuthServerOptions
does not have, and spell out the step-up check.
- organizations-memberships: same Response-style bug in two snippets,
missed by #54's table; fixed so the new lint check can pass.
Refs #11, #12, #14, #54
The guide said TOTP was not wrapped by the React SDK or mounted by the
Express adapter, and told readers to hand-roll a backend bridge and call
/auth/totp/* with fetch. Both are out of date: the client exposes
getTotpStatus, startTotpEnrollment, verifyTotpEnrollment, disableTotp,
and verifyStepUpWithTotp, useAuth() exposes verifyStepUpWithTotp, and
the Express, Fastify, and Next.js adapters mount every TOTP route except
/totp/verify-login.
Enrollment, status, disable, and step-up now use the SDK. The step-up
snippets read { data, error } instead of status?.fresh and .success.
The backend bridge is kept as a section labelled as a fallback for
backends without an adapter, and the raw route table stays as wire
reference.
Refs #13
Adds scripts/check-sdk-results.mjs to npm run lint, next to check-no-h1.mjs. Inside each code fence it finds values bound from a @seamless-auth/client or @seamless-auth/react request method (await assignment or a .then callback) and fails on any field read off them other than data or error, which covers response.ok, await response.json(), result.success, and result.providers. It also catches the inline form, (await verifyStepUpWithPasskey()).success. It only tracks SDK results, so raw fetch() and authorizedFetch() examples, which really do return a Response, are not flagged. Against the docs on main it reports every pattern listed in #54 plus the two in organizations-memberships.mdx, and it passes on this branch. Refs #54
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.
Summary
Every
@seamless-auth/reactand@seamless-auth/clientrequest method resolves toSeamlessAuthResult<T>({ data, error }, exactly one set). Several guides still read results as aResponseor an old shape. Verified againstseamless-auth-reactmain (packages/client/src/client/result.ts,createSeamlessAuthClient.ts,packages/react/src/AuthProvider.tsx,authRoutePaths.ts).react-sdk.mdx: a new Reading Results section explains the pattern once. It covers whatdataanderrorhold, what destructuring means, checkerrorfirst, whytry/catchdoes not catch failures, and the two methods that do not return a result. Other pages link back to it. The coverage list adds the TOTP methods andlogoutAllSessions(). Route paths already matchedauthRoutePaths.ts.custom-auth-ui.mdx: every step reads{ data, error }. Passkey registration documents the real{ credentialId, prfCapable }payload ondata.oauth-login.mdx: fixes a real bug.finishOAuthLoginnever throws, so the oldtry/catchsent a failed callback to the dashboard. It now checkserrorand returns before navigating.totp-step-up.mdx: leads with the SDK methods (getTotpStatus,startTotpEnrollment,verifyTotpEnrollment,disableTotp,verifyStepUpWithTotp). The adapters mount the TOTP routes, so the backend bridge is kept only as a labeled fallback for backends without an adapter.secure-routes.mdx: removes the nonexistentissueroption and fixes the step-up snippet.organizations-memberships.mdxthat Code examples read SDK results as Response or old shapes on four pages #54's table missed. A newscripts/check-sdk-results.mjs, run bynpm run lint, fails when a docs code fence reads anything butdataorerrorfrom an SDK result. It tracks SDK-bound names per fence, so genuinefetch/authorizedFetchResponse code is not flagged. Against the old docs it reports 23 findings; on this branch it passes.Testing
npm run lint(including the new check),npm run typecheck, andnpm run buildpass.Closes #10
Closes #11
Closes #12
Closes #13
Closes #14
Closes #54